Author: brane Date: Sat May 31 10:39:15 2025 New Revision: 1926006 URL: http://svn.apache.org/viewvc?rev=1926006&view=rev Log: In the CMake build: Generate a .clangd file, used by the clang language server to support editors (my Emacs!).
* build/SerfGenClangd.cmake: New; generates a .clangd file. * CMakeLists.txt: Include SerfGenClangd. Added: serf/trunk/build/SerfGenClangd.cmake Modified: serf/trunk/CMakeLists.txt Modified: serf/trunk/CMakeLists.txt URL: http://svn.apache.org/viewvc/serf/trunk/CMakeLists.txt?rev=1926006&r1=1926005&r2=1926006&view=diff ============================================================================== --- serf/trunk/CMakeLists.txt (original) +++ serf/trunk/CMakeLists.txt Sat May 31 10:39:15 2025 @@ -404,6 +404,9 @@ set_target_properties(${SERF_TARGETS} PROPERTIES OUTPUT_NAME "serf-${SERF_MAJOR_VERSION}") +# Generate the .clangd file +include(SerfGenClangd) + # Install targets install(TARGETS ${SERF_TARGETS} ARCHIVE DESTINATION "${SERF_INSTALL_LIBS}" Added: serf/trunk/build/SerfGenClangd.cmake URL: http://svn.apache.org/viewvc/serf/trunk/build/SerfGenClangd.cmake?rev=1926006&view=auto ============================================================================== --- serf/trunk/build/SerfGenClangd.cmake (added) +++ serf/trunk/build/SerfGenClangd.cmake Sat May 31 10:39:15 2025 @@ -0,0 +1,71 @@ +# =================================================================== +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# =================================================================== + +# Generate a .clangd file at the root of the source tree. + +function(SerfGenClangd) + set(target "${CMAKE_SOURCE_DIR}/.clangd") + + function(write_clangd is_path prefix) + foreach(arg ${ARGN}) + if(arg) + if(is_path) + file(TO_CMAKE_PATH "${arg}" arg) + endif() + file(APPEND ${target} " - ${prefix}${arg}\n") + endif() + endforeach() + endfunction(write_clangd) + + function(write_includes) + write_clangd(TRUE "-I" ${ARGN}) + endfunction(write_includes) + + function(write_defines) + write_clangd(TRUE "-D" ${ARGN}) + endfunction(write_defines) + + function(write_flags) + write_clangd(TRUE "" ${ARGN}) + endfunction(write_flags) + + file(WRITE ${target} "---\nCompileFlags:\n Add:\n") + write_flags("--language=c") + write_includes("${CMAKE_SOURCE_DIR}") + write_includes("${APR_INCLUDES}") + if(NOT APR_CONTAINS_APRUTIL) + write_includes("${APRUTIL_INCLUDES}") + endif() + write_includes("${OPENSSL_INCLUDE_DIR}") + write_includes("${ZLIB_INCLUDE_DIR}") + if(BROTLI_FOUND) + write_includes("${BROTLI_INCLUDES}") + endif() + if(GSSAPI_FOUND) + write_includes("${GSSAPI_INCLUDES}") + endif() + + get_directory_property(cdef COMPILE_DEFINITIONS) + write_defines(${cdef}) + + set(flags ${CMAKE_C_FLAGS}) + separate_arguments(flags) + write_flags(${flags}) +endfunction(SerfGenClangd) +SerfGenClangd()