From e96545e9f1e46b091dc8b305a6a3657374fb31b3 Mon Sep 17 00:00:00 2001 From: Sven Göthel Date: Sun, 12 May 2024 08:29:11 +0200 Subject: Produce ${CMAKE_CURRENT_SOURCE_DIR}/.clangd w/ cmake configuration if not existing (deleted the git-repo version), allowing to set all absolute path properly --- .clangd | 34 ---------------------------------- .gitignore | 1 + CMakeLists.txt | 8 ++++++++ cmake/modules/clangd.in | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 34 deletions(-) delete mode 100644 .clangd create mode 100644 cmake/modules/clangd.in diff --git a/.clangd b/.clangd deleted file mode 100644 index 58bfe1b..0000000 --- a/.clangd +++ /dev/null @@ -1,34 +0,0 @@ -#ClangTidy config is merged w/ .clang-tidy where this file takes precedence -#Diagnostics: -# ClangTidy: -# Add: [clang-diagnostic-*, clang-analyzer-*, modernize-*, bugprone-*] -# -# Remove: [modernize-use-auto, modernize-use-nodiscard, modernize-use-using, modernize-use-trailing-return-type, -# modernize-avoid-c-arrays, modernize-use-default-member-init, modernize-return-braced-init-list, -# modernize-avoid-bind, modernize-use-transparent-functors, -# bugprone-reserved-identifier, bugprone-easily-swappable-parameters, bugprone-assignment-in-if-condition, -# bugprone-misplaced-widening-cast, bugprone-branch-clone] -# -# CheckOptions: -# modernize-use-default-member-init.UseAssignment: true - -# Tell clangd to use the compile_commands.json file in the build/default folder -# Add: [-isystem, /usr/local/projects/jausoft/gamp/jaulib/include] -# Add: [-isystem, ../jaulib/include] -CompileFlags: - CompilationDatabase: build/default - Add: [-isystem, /usr/local/projects/jausoft/gamp/jaulib/include] - -Diagnostics: - UnusedIncludes: Strict - -InlayHints: - Enabled: No - BlockEnd: Yes - Designators: No - ParameterNames: Yes - DeducedTypes: Yes - TypeNameLimit: 24 - -Hover: - ShowAKA: Yes diff --git a/.gitignore b/.gitignore index 66205fa..43cc61b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ snaps/ /compile_commands.json *~ *.log +.clangd diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b86ed7..af52bce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,14 @@ endif() include(WasmSetup.cmake) JaulibSetup() +if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.clangd) +# Fixup clangd w/ absolute path +set (gamp_clangd_source_args "-isystem, ${CMAKE_CURRENT_SOURCE_DIR}/jaulib/include, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/jaulib/src, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/jaulib/java_jni/jni, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/jaulib/java_jni/jni/jau, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/jaulib/test") +set (gamp_clangd_source_args "${gamp_clangd_source_args} -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/include, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/src, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/test") +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/clangd.in + ${CMAKE_CURRENT_SOURCE_DIR}/.clangd) +endif() + # this is the library version, derived from git tag and revision set (gamp_VERSION_MAJOR ${VERSION_MAJOR}) set (gamp_VERSION_MINOR ${VERSION_MINOR}) diff --git a/cmake/modules/clangd.in b/cmake/modules/clangd.in new file mode 100644 index 0000000..9388250 --- /dev/null +++ b/cmake/modules/clangd.in @@ -0,0 +1,32 @@ +#ClangTidy config is merged w/ .clang-tidy where this file takes precedence +#Diagnostics: +# ClangTidy: +# Add: [clang-diagnostic-*, clang-analyzer-*, modernize-*, bugprone-*] +# +# Remove: [modernize-use-auto, modernize-use-nodiscard, modernize-use-using, modernize-use-trailing-return-type, +# modernize-avoid-c-arrays, modernize-use-default-member-init, modernize-return-braced-init-list, +# modernize-avoid-bind, modernize-use-transparent-functors, +# bugprone-reserved-identifier, bugprone-easily-swappable-parameters, bugprone-assignment-in-if-condition, +# bugprone-misplaced-widening-cast, bugprone-branch-clone] +# +# CheckOptions: +# modernize-use-default-member-init.UseAssignment: true + +# Tell clangd to use the compile_commands.json file in the build/default folder +CompileFlags: + CompilationDatabase: @CMAKE_CURRENT_BINARY_DIR@ + Add: [@gamp_clangd_source_args@] + +Diagnostics: + UnusedIncludes: Strict + +InlayHints: + Enabled: No + BlockEnd: Yes + Designators: No + ParameterNames: Yes + DeducedTypes: Yes + TypeNameLimit: 24 + +Hover: + ShowAKA: Yes -- cgit v1.2.3