Skip to content

Commit 3ce5cba

Browse files
committed
Move clangd integration to core setup and improve placement
- Moved compile_commands.json symlink creation from testing to main setup - Now available for ALL top-level builds, not just when testing - Ensures VSCode/clangd integration works during development - Removed duplicate clangd setup from testing module
1 parent 3ebc75d commit 3ce5cba

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

cmake/cpp-library-testing.cmake

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ function(_cpp_library_setup_testing)
2121
CPMAddPackage("gh:doctest/[email protected]")
2222
endif()
2323

24-
# Create symlink to compile_commands.json for clangd
25-
if(CMAKE_EXPORT_COMPILE_COMMANDS)
26-
add_custom_target(clangd_compile_commands ALL
27-
COMMAND ${CMAKE_COMMAND} -E create_symlink
28-
${CMAKE_BINARY_DIR}/compile_commands.json
29-
${CMAKE_SOURCE_DIR}/compile_commands.json
30-
COMMENT "Creating symlink to compile_commands.json for clangd"
31-
)
32-
endif()
33-
3424
# Add test executables
3525
foreach(test IN LISTS ARG_TESTS)
3626
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/${test}.cpp" OR

cpp-library.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ function(cpp_library_setup)
8383
return() # Early return for lightweight consumer mode
8484
endif()
8585

86+
# Create symlink to compile_commands.json for clangd
87+
if(CMAKE_EXPORT_COMPILE_COMMANDS)
88+
add_custom_target(clangd_compile_commands ALL
89+
COMMAND ${CMAKE_COMMAND} -E create_symlink
90+
${CMAKE_BINARY_DIR}/compile_commands.json
91+
${CMAKE_SOURCE_DIR}/compile_commands.json
92+
COMMENT "Creating symlink to compile_commands.json for clangd"
93+
)
94+
endif()
95+
8696
# Generate CMakePresets.json (unless disabled)
8797
if(NOT ARG_NO_PRESETS)
8898
_cpp_library_generate_presets()

0 commit comments

Comments
 (0)