Skip to content

Commit 3946448

Browse files
committed
Bazel/CMake: create compilation database by default
If on Windows and not in developer mode, the creation of the symbolic link can be skipped by setting `CREATE_COMPILATION_DATABASE_LINK` to `OFF`.
1 parent 739702b commit 3946448

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

misc/bazel/cmake/setup.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
option(BUILD_SHARED_LIBS "" 0)
1+
option(BUILD_SHARED_LIBS "Build and use shared libraries" 0)
2+
option(CREATE_COMPILATION_DATABASE_LINK "Create compilation database link. Implies CMAKE_EXPORT_COMPILE_COMMANDS" 1)
3+
4+
if (CREATE_COMPILATION_DATABASE_LINK)
5+
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
6+
endif ()
27

38
macro(bazel)
49
execute_process(COMMAND bazel ${ARGN} COMMAND_ERROR_IS_FATAL ANY OUTPUT_STRIP_TRAILING_WHITESPACE)
@@ -20,6 +25,6 @@ foreach (target ${BAZEL_GENERATE_CMAKE_TARGETS})
2025
include(${BAZEL_WORKSPACE}/bazel-bin/${target}.cmake)
2126
endforeach ()
2227

23-
if (CMAKE_EXPORT_COMPILE_COMMANDS)
28+
if (CREATE_COMPILATION_DATABASE_LINK)
2429
file(CREATE_LINK ${PROJECT_BINARY_DIR}/compile_commands.json ${PROJECT_SOURCE_DIR}/compile_commands.json SYMBOLIC)
2530
endif ()

0 commit comments

Comments
 (0)