Skip to content

Commit 00465be

Browse files
committed
Automatically symlink compile_commands.json
compile_commands.json allows IDEs to provide go-to definition etc. support, but it gets generated in CMAKE_BINARY_DIR, which may be out of tree when doing an out-of-source build. So, symlink it automatically to allow IDEs to pick it up.
1 parent 5d96740 commit 00465be

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/CMake/VisualStudioToolset.cmake")
99

1010
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1111

12+
# Create symlink to compile_commands.json for IDE to pick it up
13+
execute_process(
14+
COMMAND
15+
${CMAKE_COMMAND} -E create_symlink
16+
${CMAKE_BINARY_DIR}/compile_commands.json
17+
${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json)
18+
1219
# includes
1320
SET(
1421
CMAKE_MODULE_PATH

0 commit comments

Comments
 (0)