From fc5ad7f1374d7da7dd5bb8e5e5a6c5dfed1dc14a Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 12 Oct 2023 11:54:14 +0200 Subject: [PATCH] feat: extract compile command handling from CMakeLists.txt --- CMakeLists.txt | 7 ++----- cmake/ExportCompileCommands.cmake | 6 ++++++ 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 cmake/ExportCompileCommands.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d5d4657..e50fdb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,12 +5,9 @@ project( VERSION 0.1.0 LANGUAGES CXX) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") -if(CMAKE_EXPORT_COMPILE_COMMANDS) - set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES - ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) -endif() +include(ExportCompileCommands) configure_file("${PROJECT_SOURCE_DIR}/include/version.h.in" "${PROJECT_BINARY_DIR}/include/version.h") diff --git a/cmake/ExportCompileCommands.cmake b/cmake/ExportCompileCommands.cmake new file mode 100644 index 0000000..5c904f5 --- /dev/null +++ b/cmake/ExportCompileCommands.cmake @@ -0,0 +1,6 @@ +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +if(CMAKE_EXPORT_COMPILE_COMMANDS) + set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES + ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) +endif()