From 2f1f20c8c3b8571bace9fc26fe49286aa94f2658 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 27 Jul 2016 21:38:40 +0200 Subject: [PATCH] Generate config header in extra module --- CMakeLists.txt | 1 + cmake/modules/BasicConfig.cmake | 13 ------------- cmake/modules/ConfigHeader.cmake | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 cmake/modules/ConfigHeader.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ba92527..36f0841 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,3 +116,4 @@ include(WindowsResources) include(LibraryTarget) include(TestTarget) include(Doxygen) +include(ConfigHeader) diff --git a/cmake/modules/BasicConfig.cmake b/cmake/modules/BasicConfig.cmake index 49eed69..ebc20e3 100644 --- a/cmake/modules/BasicConfig.cmake +++ b/cmake/modules/BasicConfig.cmake @@ -35,19 +35,6 @@ endif() # set TARGET_EXECUTABLE which is used to refer to the target executable at its installation location set(TARGET_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/bin/${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}") -# find config.h template -include(TemplateFinder) -find_template_file("config.h" CPP_UTILITIES CONFIG_H_TEMPLATE_FILE) - -# add configuration header -configure_file( - "${CONFIG_H_TEMPLATE_FILE}" - "${CMAKE_CURRENT_BINARY_DIR}/resources/config.h" -) - -# ensure generated include files are found -include_directories("${CMAKE_CURRENT_BINARY_DIR}") - # disable new ABI (can't catch ios_base::failure with new ABI) option(FORCE_OLD_ABI "specifies whether usage of old ABI should be forced" OFF) if(FORCE_OLD_ABI) diff --git a/cmake/modules/ConfigHeader.cmake b/cmake/modules/ConfigHeader.cmake new file mode 100644 index 0000000..abc3a7d --- /dev/null +++ b/cmake/modules/ConfigHeader.cmake @@ -0,0 +1,15 @@ +# before including this module, all relevant variables must be set +# (just include this module as last one since nothing should depend on it) + +# find config.h template +include(TemplateFinder) +find_template_file("config.h" CPP_UTILITIES CONFIG_H_TEMPLATE_FILE) + +# add configuration header +configure_file( + "${CONFIG_H_TEMPLATE_FILE}" + "${CMAKE_CURRENT_BINARY_DIR}/resources/config.h" +) + +# ensure generated include files can be included via #include "resources/config.h" +include_directories("${CMAKE_CURRENT_BINARY_DIR}")