-
Notifications
You must be signed in to change notification settings - Fork 16
/
CMakeLists.txt
156 lines (129 loc) · 4.08 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
cmake_minimum_required(VERSION 3.14)
project(
"tuplet"
VERSION 2.1.1
DESCRIPTION "A Lightweight Tuple Implementation for Modern C++"
HOMEPAGE_URL "https://github.com/codeinred/tuplet/"
LANGUAGES CXX)
add_library(tuplet INTERFACE)
add_library(
tuplet::tuplet
ALIAS
tuplet)
# For ${CMAKE_INSTALL_<DIR>} variables that are standarized
include(GNUInstallDirs)
list(
APPEND
CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}/cmake")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
target_compile_features(tuplet INTERFACE cxx_std_17)
target_include_directories(
tuplet INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
# Installation
# See: https://dominikberner.ch/cmake-interface-lib/
install(
TARGETS tuplet
EXPORT tuplet_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"tupletConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/tupletConfig.cmake.in"
"${PROJECT_BINARY_DIR}/tupletConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/tuplet/cmake)
install(
EXPORT tuplet_Targets
FILE tupletTargets.cmake
NAMESPACE tuplet::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/tuplet/cmake)
install(FILES "${PROJECT_BINARY_DIR}/tupletConfig.cmake"
"${PROJECT_BINARY_DIR}/tupletConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/tuplet/cmake)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/tuplet
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
include(helper)
option(
BUILD_TESTING
"Build testing for tuplet"
ON)
if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
# Enable exception handling on MSVC
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
endif()
include(CTest)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# Add all files in directory test as tests, and link against tuplet and
# threads
#if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# target_compile_options(
# test_kilo_tuple
# PRIVATE
# -fbracket-depth=1000)
#endif()
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_DOWNLOAD_DEPENDENCIES OFF)
# Find the benchmark library, or download it in build/_deps
find_or_fetch(
benchmark
https://github.com/google/benchmark.git
main)
find_or_fetch(
fmt
https://github.com/fmtlib/fmt.git
master)
find_or_fetch(
Catch2
https://github.com/catchorg/catch2.git
v3.3.2
3.3.2)
FetchContent_MakeAvailable(${remote_dependencies})
add_executable(
bench
bench/bench-heterogenous.cpp
bench/bench-homogenous.cpp
bench/bench-single-elem.cpp)
file(GLOB test_files CONFIGURE_DEPENDS test/*.cpp)
add_executable(test_tuplet ${test_files})
target_link_libraries(
test_tuplet
tuplet::tuplet
fmt::fmt
Catch2::Catch2WithMain)
target_link_libraries(
bench
tuplet::tuplet
benchmark::benchmark_main)
include(CTest)
include(Catch)
catch_discover_tests(test_tuplet)
if(cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
add_executable(test_tuplet_cpp_20 ${test_files})
target_link_libraries(
test_tuplet_cpp_20
tuplet::tuplet
fmt::fmt
Catch2::Catch2WithMain)
target_compile_features(test_tuplet_cpp_20 PRIVATE cxx_std_20)
list(
APPEND
CMAKE_MODULE_PATH
${CMAKE_INSTALL_PREFIX}/lib/cmake/Catch2)
list(
APPEND
CMAKE_MODULE_PATH
${catch2_SOURCE_DIR}/extras)
catch_discover_tests(
test_tuplet_cpp_20
TEST_SUFFIX " (cpp 20)")
endif()
endif()