Skip to content

Commit c8ee663

Browse files
committed
Fix cmake initialization regarding policy configuration
1 parent 8f9950e commit c8ee663

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

CMakeLists.txt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,20 @@
66
# CMake version
77
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
88

9-
# Include cmake modules
9+
#
10+
# Configure CMake environment
11+
#
12+
13+
# Register general cmake commands
14+
include(cmake/Custom.cmake)
1015

16+
# Set policies
17+
set_policy(CMP0028 NEW) # ENABLE CMP0028: Double colon in target name means ALIAS or IMPORTED target.
18+
set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted.
19+
set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default.
20+
set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types.
21+
22+
# Include cmake modules
1123
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1224

1325
include(GenerateExportHeader)
@@ -19,15 +31,10 @@ if (${CMAKE_VERSION} VERSION_GREATER "3.2")
1931
include(WriteCompilerDetectionHeader OPTIONAL RESULT_VARIABLE WriterCompilerDetectionHeaderFound)
2032
endif()
2133

34+
# Include custom cmake modules
2235
include(cmake/GetGitRevisionDescription.cmake)
23-
include(cmake/Custom.cmake)
2436
include(cmake/HealthCheck.cmake)
25-
26-
# Set policies
27-
set_policy(CMP0028 NEW) # ENABLE CMP0028: Double colon in target name means ALIAS or IMPORTED target.
28-
set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted.
29-
set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default.
30-
set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types.
37+
include(cmake/GenerateTemplateExportHeader.cmake)
3138

3239

3340
#

cmake/Custom.cmake

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,3 @@ function(list_extract OUTPUT REGEX)
4444
set(${OUTPUT} ${${OUTPUT}} PARENT_SCOPE)
4545

4646
endfunction(list_extract)
47-
48-
49-
# Creates an export header similar to generate_export_header, but for templates.
50-
# The main difference is that for MSVC, templates must not get exported.
51-
# When the file ${export_file} is included in source code, the macro ${target_id}_TEMPLATE_API
52-
# may get used to define public visibility for templates on GCC and Clang platforms.
53-
function(generate_template_export_header target target_id export_file)
54-
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
55-
configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_msvc_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file})
56-
else()
57-
configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file})
58-
endif()
59-
endfunction()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
# Creates an export header similar to generate_export_header, but for templates.
3+
# The main difference is that for MSVC, templates must not get exported.
4+
# When the file ${export_file} is included in source code, the macro ${target_id}_TEMPLATE_API
5+
# may get used to define public visibility for templates on GCC and Clang platforms.
6+
function(generate_template_export_header target target_id export_file)
7+
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
8+
configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_msvc_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file})
9+
else()
10+
configure_file(${PROJECT_SOURCE_DIR}/source/codegeneration/template_api.h.in ${CMAKE_CURRENT_BINARY_DIR}/${export_file})
11+
endif()
12+
endfunction()

0 commit comments

Comments
 (0)