From 2fc26c649a1a2b242e9620159b27212f9d8a38cc Mon Sep 17 00:00:00 2001 From: Katze719 Date: Wed, 3 Dec 2025 19:36:16 +0100 Subject: [PATCH] Update CMakeLists.txt to correct output directory for generated git version and refine compile commands condition - Changed the output directory for the generated git version from `${CMAKE_SOURCE_DIR}` to `${CMAKE_CURRENT_SOURCE_DIR}` to ensure proper path resolution. - Updated the condition for exporting compile commands to check if the project is top-level, enhancing the build configuration logic. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be265db..aecf08b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ include(${cmake-git-versioning_SOURCE_DIR}/cmake/cmake-git-versioning.cmake) # Get git version info (sets CMake variables) get_git_version_info() -generate_git_version(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/include/cpp_core) +generate_git_version(OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/cpp_core) project( cpp-core @@ -91,7 +91,7 @@ install( DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cpp_core ) -if(CMAKE_EXPORT_COMPILE_COMMANDS AND EXISTS "${CMAKE_BINARY_DIR}/compile_commands.json") +if(PROJECT_IS_TOP_LEVEL AND CMAKE_EXPORT_COMPILE_COMMANDS AND EXISTS "${CMAKE_BINARY_DIR}/compile_commands.json") add_custom_target( copy-compile-commands ALL