-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
152 lines (123 loc) · 3.84 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
cmake_minimum_required(VERSION 3.15)
# Contents generated by 'cmake-init -h', manually edited to a standalone
# single file, with includes expanded inline
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(
FATAL_ERROR
"In-source builds are not supported. "
"Make a new directory (e.g., 'build'), and run CMake from there. "
"You may need to delete 'CMakeCache.txt' and 'CMakeFiles/' first."
)
endif()
project(
tupl
VERSION 0.3.0
DESCRIPTION "C++20 aggregate tuple"
HOMEPAGE_URL "https://github.com/Lemurian-Labs/tupl"
LANGUAGES CXX
)
# PROJECT_IS_TOP_LEVEL variable is set by project() in CMake 3.21+
string(
COMPARE EQUAL
"${CMAKE_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}"
PROJECT_IS_TOP_LEVEL
)
# ---- Warning guard ----
# target_include_directories with SYSTEM modifier requests the compiler
# to omit warnings from the provided paths, if the compiler supports it.
# This is to provide a user experience similar to find_package when
# add_subdirectory or FetchContent is used to consume this project
set(tupl_warning_guard "")
if(NOT PROJECT_IS_TOP_LEVEL)
option(
tupl_INCLUDES_WITH_SYSTEM
"Use SYSTEM modifier for tupl's includes, disabling warnings"
ON
)
mark_as_advanced(tupl_INCLUDES_WITH_SYSTEM)
if(tupl_INCLUDES_WITH_SYSTEM)
set(tupl_warning_guard SYSTEM)
endif()
endif()
# ---- Fetch dependency; c_array_support (for C array members) ----
include(FetchContent)
FetchContent_Declare(
c_array_support
GIT_REPOSITORY https://github.com/willwray/c_array_support
GIT_TAG v0.5
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
)
FetchContent_MakeAvailable(c_array_support)
add_library(c_array_support INTERFACE)
target_include_directories(
c_array_support INTERFACE ${c_array_support_SOURCE_DIR}/)
# ---- Declare library ----
add_library(tupl_tupl INTERFACE)
add_library(tupl::tupl ALIAS tupl_tupl)
set_property(
TARGET tupl_tupl PROPERTY
EXPORT_NAME tupl
)
target_include_directories(
tupl_tupl
INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>"
)
target_compile_features(tupl_tupl INTERFACE cxx_std_20)
# ---- Install rules ----
if(NOT CMAKE_SKIP_INSTALL_RULES)
# include(cmake/install-rules.cmake)
# install-rules.cmake - BEGIN ---------------------
if(PROJECT_IS_TOP_LEVEL)
set(CMAKE_INSTALL_INCLUDEDIR include/tupl CACHE PATH "")
endif()
# Project is configured with no languages, so tell GNUInstallDirs the lib dir
set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
# find_package(<package>) call for consumers to find this project
set(package tupl)
install(
DIRECTORY include/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT tupl_Development
)
install(
TARGETS tupl_tupl
EXPORT tuplTargets
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
write_basic_package_version_file(
"${package}ConfigVersion.cmake"
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)
# Allow package maintainers to freely override the path for the configs
set(
tupl_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/${package}"
CACHE PATH "CMake package config location relative to the install prefix"
)
mark_as_advanced(tupl_INSTALL_CMAKEDIR)
install(
FILES cmake/install-config.cmake
DESTINATION "${tupl_INSTALL_CMAKEDIR}"
RENAME "${package}Config.cmake"
COMPONENT tupl_Development
)
install(
FILES "${PROJECT_BINARY_DIR}/${package}ConfigVersion.cmake"
DESTINATION "${tupl_INSTALL_CMAKEDIR}"
COMPONENT tupl_Development
)
install(
EXPORT tuplTargets
NAMESPACE tupl::
DESTINATION "${tupl_INSTALL_CMAKEDIR}"
COMPONENT tupl_Development
)
if(PROJECT_IS_TOP_LEVEL)
include(CPack)
endif()
# - install-rules.cmake - BEGIN ---------------------
endif()