From 64d2732b4e630922eb8cee0501faadfb4b68b3af Mon Sep 17 00:00:00 2001 From: Dominik Meyer Date: Tue, 19 Nov 2024 18:20:20 +0100 Subject: [PATCH] feat: support multiple COMPD definitions --- cmake/Modules/compdb.cmake | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cmake/Modules/compdb.cmake b/cmake/Modules/compdb.cmake index a169208..ddf8e1e 100644 --- a/cmake/Modules/compdb.cmake +++ b/cmake/Modules/compdb.cmake @@ -10,14 +10,16 @@ find_program(COMPDB_PATH ) +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) -if (COMPDB_PATH) - IF(NOT TARGET COMPD) - add_custom_target(COMPD - ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${COMPDB_PATH} -p ${CMAKE_CURRENT_BINARY_DIR} list >compile_commands.json - ) + if (COMPDB_PATH) + IF(NOT TARGET COMPD) + add_custom_target(COMPD + ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${COMPDB_PATH} -p ${CMAKE_CURRENT_BINARY_DIR} list >compile_commands.json + ) + endif() endif() endif()