From 0a0044cc22800470bbb09eb7416f85c2cc2aa9b2 Mon Sep 17 00:00:00 2001 From: Willy Scheibel Date: Tue, 9 May 2017 14:42:09 +0200 Subject: [PATCH] Apply cmake-init 689c8a9a22a77848c15209fc155afc368e3b9b59 --- CMakeLists.txt | 25 +++++++++++++++--------- cmake/Custom.cmake | 13 ------------ cmake/GenerateTemplateExportHeader.cmake | 12 ++++++++++++ 3 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 cmake/GenerateTemplateExportHeader.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b6bd0ab..70f06f60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,20 @@ # CMake version cmake_minimum_required(VERSION 3.0 FATAL_ERROR) -# Include cmake modules +# +# Configure CMake environment +# + +# Register general cmake commands +include(cmake/Custom.cmake) +# Set policies +set_policy(CMP0028 NEW) # ENABLE CMP0028: Double colon in target name means ALIAS or IMPORTED target. +set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted. +set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default. +set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types. + +# Include cmake modules list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(GenerateExportHeader) @@ -19,15 +31,10 @@ if (${CMAKE_VERSION} VERSION_GREATER "3.2") include(WriteCompilerDetectionHeader OPTIONAL RESULT_VARIABLE WriterCompilerDetectionHeaderFound) endif() +# Include custom cmake modules include(cmake/GetGitRevisionDescription.cmake) -include(cmake/Custom.cmake) include(cmake/HealthCheck.cmake) - -# Set policies -set_policy(CMP0028 NEW) # ENABLE CMP0028: Double colon in target name means ALIAS or IMPORTED target. -set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted. -set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default. -set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types. +include(cmake/GenerateTemplateExportHeader.cmake) # @@ -53,7 +60,7 @@ set(META_VERSION_PATCH "0") set(META_VERSION_REVISION "${GIT_REV}") set(META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}") set(META_NAME_VERSION "${META_PROJECT_NAME} v${META_VERSION} (${META_VERSION_REVISION})") -set(META_CMAKE_INIT_SHA "8f9950e7c13cf10521cb5d4c4d8be0d6bf8fcd0c") +set(META_CMAKE_INIT_SHA "689c8a9a22a77848c15209fc155afc368e3b9b59") string(MAKE_C_IDENTIFIER ${META_PROJECT_NAME} META_PROJECT_ID) string(TOUPPER ${META_PROJECT_ID} META_PROJECT_ID) diff --git a/cmake/Custom.cmake b/cmake/Custom.cmake index 4e448205..e0e690fc 100644 --- a/cmake/Custom.cmake +++ b/cmake/Custom.cmake @@ -44,16 +44,3 @@ function(list_extract OUTPUT REGEX) set(${OUTPUT} ${${OUTPUT}} PARENT_SCOPE) endfunction(list_extract) - - -# Creates an export header similar to generate_export_header, but for templates. -# The main difference is that for MSVC, templates must not get exported. -# When the file ${export_file} is included in source code, the macro ${target_id}_TEMPLATE_API -# may get used to define public visibility for templates on GCC and Clang platforms. -function(generate_template_export_header target target_id export_file) - if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") - configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_msvc_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file}) - else() - configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file}) - endif() -endfunction() diff --git a/cmake/GenerateTemplateExportHeader.cmake b/cmake/GenerateTemplateExportHeader.cmake new file mode 100644 index 00000000..7f8ea880 --- /dev/null +++ b/cmake/GenerateTemplateExportHeader.cmake @@ -0,0 +1,12 @@ + +# Creates an export header similar to generate_export_header, but for templates. +# The main difference is that for MSVC, templates must not get exported. +# When the file ${export_file} is included in source code, the macro ${target_id}_TEMPLATE_API +# may get used to define public visibility for templates on GCC and Clang platforms. +function(generate_template_export_header target target_id export_file) + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_msvc_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file}) + else() + configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file}) + endif() +endfunction()