-
Notifications
You must be signed in to change notification settings - Fork 38
/
CMakeLists.txt
121 lines (96 loc) · 3.49 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
cmake_minimum_required(VERSION 3.5)
set(KANGARU_VERSION_MAJOR "4")
set(KANGARU_VERSION_MINOR "3")
set(KANGARU_VERSION_PATCH "2")
set(KANGARU_VERSION "${KANGARU_VERSION_MAJOR}.${KANGARU_VERSION_MINOR}.${KANGARU_VERSION_PATCH}")
project(kangaru VERSION ${KANGARU_VERSION} LANGUAGES CXX)
option(KANGARU_BUILD_EXAMPLES "Build kangaru examples" false)
option(KANGARU_INSTALL "Generate kangaru installation target" true)
option(KANGARU_EXPORT "Export kangaru source tree as package" true)
option(KANGARU_REVERSE_DESTRUCTION "Reverse destruction order in the container mimicking a stack" false)
option(KANGARU_HASH_TYPE_ID "Generate the type IDs using the hashed type names" false)
option(KANGARU_NO_EXCEPTION "Disable exceptions by replacing throws by asserts" false)
option(KANGARU_BENCHMARK "Build benchmark binaries" false)
option(KANGARU_TEST "Build test binaries" false)
option(KANGARU_TEST_CXX14 "Build C++14 test binaries" false)
option(KANGARU_TEST_CXX17 "Build C++17 test binaries" false)
set(KGR_KANGARU_NOEXCEPTION ${KANGARU_NO_EXCEPTION})
set(KGR_KANGARU_REVERSE_DESTRUCTION ${KANGARU_REVERSE_DESTRUCTION})
set(KGR_KANGARU_HASH_TYPE_ID ${KANGARU_HASH_TYPE_ID})
if(NOT KGR_KANGARU_REVERSE_DESTRUCTION)
message(WARNING
"The recommended behavior is to enable reverse destruction. This option will the the "
"default behavior for kangaru 5.x.y. Not enabling this option is considered deprecated."
)
endif()
configure_file(
cmake/config/config.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/generated/include/kangaru/detail/config.hpp
@ONLY
)
if(KANGARU_TEST_CXX14 OR KANGARU_TEST_CXX17 OR KANGARU_TEST)
set(KANGARU_ENABLE_TESTS true)
endif()
set(KANGARU_INSTALL_INCLUDE_DIR "include")
add_library(kangaru INTERFACE)
add_library(kangaru::kangaru ALIAS kangaru)
target_compile_features(kangaru INTERFACE cxx_std_11)
target_include_directories(kangaru INTERFACE
$<INSTALL_INTERFACE:${KANGARU_INSTALL_INCLUDE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated/include>
)
if(KANGARU_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(KANGARU_ENABLE_TESTS)
enable_testing()
add_subdirectory(test)
endif()
if(KANGARU_BENCHMARK)
add_subdirectory(benchmark)
endif()
if(KANGARU_EXPORT)
export(PACKAGE kangaru)
endif()
if(KANGARU_INSTALL)
set(KANGARU_CONFIG_PATH "lib/cmake/kangaru")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/kangaruConfigVersion.cmake"
VERSION ${KANGARU_VERSION}
COMPATIBILITY SameMajorVersion
)
# build tree package config
configure_file(
cmake/config/kangaruBuildConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/kangaruConfig.cmake
@ONLY
)
# install tree package config
configure_package_config_file(
cmake/config/kangaruConfig.cmake.in
${KANGARU_CONFIG_PATH}/kangaruConfig.cmake
INSTALL_DESTINATION ${KANGARU_CONFIG_PATH}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(
DIRECTORY include/kangaru ${CMAKE_CURRENT_BINARY_DIR}/generated/include/kangaru
DESTINATION ${KANGARU_INSTALL_INCLUDE_DIR} FILES_MATCHING PATTERN "*.hpp"
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${KANGARU_CONFIG_PATH}/kangaruConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/kangaruConfigVersion.cmake"
DESTINATION ${KANGARU_CONFIG_PATH}
)
install(TARGETS kangaru EXPORT kangaruTargets)
export(
EXPORT kangaruTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/kangaruTargets.cmake"
)
install(
EXPORT kangaruTargets FILE kangaruTargets.cmake
DESTINATION ${KANGARU_CONFIG_PATH}
)
endif()