-
Notifications
You must be signed in to change notification settings - Fork 31
/
CMakeLists.txt
127 lines (100 loc) · 3.64 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
cmake_minimum_required(VERSION 3.23)
project(flux CXX)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
set(CMAKE_CXX_EXTENSIONS Off)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
add_library(flux INTERFACE)
add_library(flux::flux ALIAS flux)
file(GLOB_RECURSE FLUX_HEADERS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp" )
target_sources(flux INTERFACE
FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
FILES ${FLUX_HEADERS})
target_compile_features(flux INTERFACE $<IF:$<CXX_COMPILER_ID:MSVC>,cxx_std_23,cxx_std_20>)
set_target_properties(flux PROPERTIES CXX_STANDARD_REQUIRED On)
add_library(flux-internal INTERFACE)
target_link_libraries(flux-internal INTERFACE flux)
set_target_properties(flux-internal PROPERTIES CXX_EXTENSIONS Off)
target_compile_options(flux-internal INTERFACE
$<$<CXX_COMPILER_ID:Clang,AppleClang,GNU,Intel>:
-Wall -Wextra -Wconversion -pedantic
-fno-omit-frame-pointer
-ftemplate-backtrace-limit=0
>
$<$<CXX_COMPILER_ID:GNU>: -fconcepts-diagnostics-depth=2>
$<$<CXX_COMPILER_ID:Clang,AppleClang>: -fconstexpr-backtrace-limit=0>
$<$<CXX_COMPILER_ID:MSVC>:
# Various options for closer standard conformance
/utf-8 /Zc:__cplusplus /Zc:throwingNew /Zc:inline /Zc:externConstexpr
/Zc:templateScope /Zc:checkGwOdr /Zc:enumTypes
/W4
/wd4459 # local variable name hides global variable
/wd4702 # unreachable code
/wd4100 # unreferenced formal parameter
>
)
option(FLUX_BUILD_DOCS "Build Flux documentation (requires Sphinx)" Off)
option(FLUX_BUILD_EXAMPLES "Build Flux examples" ${PROJECT_IS_TOP_LEVEL})
option(FLUX_BUILD_TESTS "Build Flux tests" ${PROJECT_IS_TOP_LEVEL})
option(FLUX_BUILD_BENCHMARKS "Build Flux benchmarks" Off)
option(FLUX_BUILD_TOOLS "Build single-header generator tool" Off)
option(FLUX_BUILD_MODULE "Build C++20 module (experimental)" Off)
option(FLUX_BUILD_TESTS_USING_MODULE "Build tests using modules (experimental)" Off)
option(FLUX_ENABLE_ASAN "Enable Address Sanitizer for tests" Off)
option(FLUX_ENABLE_UBSAN "Enable Undefined Behaviour Sanitizer for tests" Off)
if (FLUX_BUILD_DOCS)
add_subdirectory(docs)
endif()
if (FLUX_BUILD_EXAMPLES)
enable_testing()
add_subdirectory(example)
endif()
if (FLUX_BUILD_BENCHMARKS)
add_subdirectory(benchmark)
endif()
if (FLUX_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
if (FLUX_BUILD_TOOLS)
add_subdirectory(tools)
endif()
if (FLUX_BUILD_MODULE)
if(CMAKE_VERSION VERSION_LESS "3.28.0")
message(FATAL_ERROR "Modules support requires CMake v3.28 or later (currently v${CMAKE_VERSION})")
else()
add_subdirectory(module)
endif()
endif()
set(FLUX_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/flux)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/flux-version.cmake"
VERSION -1 # When there is a PROJECT_VERSION, remove this line
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/flux-config.cmake.in"
"${PROJECT_BINARY_DIR}/flux-config.cmake"
INSTALL_DESTINATION ${FLUX_INSTALL_CMAKE_DIR}
)
# set target installation location properties and associates it with the targets files
install(
TARGETS flux
EXPORT flux-targets
FILE_SET HEADERS
)
#install the targets files
install(
EXPORT flux-targets
NAMESPACE flux::
DESTINATION ${FLUX_INSTALL_CMAKE_DIR}
)
# install the config and version files
install(
FILES
"${PROJECT_BINARY_DIR}/flux-config.cmake"
"${PROJECT_BINARY_DIR}/flux-version.cmake"
DESTINATION ${FLUX_INSTALL_CMAKE_DIR}
)