-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
178 lines (136 loc) · 5.65 KB
/
CMakeLists.txt
File metadata and controls
178 lines (136 loc) · 5.65 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# Written in 2017, 2019, 2022-2023 by Henrik Steffen Gaßmann <henrik@gassmann.onl>
#
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any warranty.
#
# You should have received a copy of the CC0 Public Domain Dedication
# along with this software. If not, see
#
# http://creativecommons.org/publicdomain/zero/1.0/
#
########################################################################
cmake_minimum_required(VERSION 3.25)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/tools/cmake/")
########################################################################
# configure vcpkg from environment vars if possible
include(VcpkgDefaults)
if (BUILD_TESTING OR NOT DEFINED BUILD_TESTING)
list(APPEND VCPKG_MANIFEST_FEATURES "tests")
endif()
if (DPLX_DLOG_USE_BOOST_ATOMIC_REF)
list(APPEND VCPKG_MANIFEST_FEATURES "boost-atomic-ref")
endif()
########################################################################
project(deeplog
VERSION 0.0.0.14
LANGUAGES CXX
)
include(EnforceOutOfSourceBuilds)
include(CheckStdAtomicRefSupport)
include(CMakeDependentOption)
include(CMakePackageConfigHelpers)
include(FeatureSummary)
include(GNUInstallDirs)
include(SourceHelpers)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if (BUILD_TESTING)
enable_testing()
endif()
check_std_atomic_ref_support(DPLX_DLOG_HAS_STD_ATOMIC_REF)
########################################################################
# options
option(DPLX_DLOG_DISABLE_WORKAROUNDS "Disable all workarounds" OFF)
option(DPLX_DLOG_FLAG_OUTDATED_WORKAROUNDS "Emit compiler errors for workarounds which are active, but haven't been validated for this version" OFF)
option(DPLX_DLOG_DISABLE_IMPLICIT_CONTEXT "Disable implicit context support via TLS" OFF)
cmake_dependent_option(DPLX_DLOG_USE_BOOST_ATOMIC_REF "Use boost::atomic_ref instead of std::atomic_ref" OFF "DPLX_DLOG_HAS_STD_ATOMIC_REF" ON)
option(BUILD_EXAMPLES "Build the example executables" OFF)
set(DLOG_LLFIO_TARGET "sl" CACHE STRING "The llfio target to link against, can be 'hl', 'sl' or 'dl'")
set_property(CACHE DLOG_LLFIO_TARGET PROPERTY STRINGS "hl;sl;dl")
########################################################################
# dependencies
set(Boost_NO_WARN_NEW_VERSIONS ON)
set(DLOG_REQUIRED_BOOST_COMPONENTS config mp11 unordered variant2)
if (DPLX_DLOG_USE_BOOST_ATOMIC_REF)
list(APPEND DLOG_REQUIRED_BOOST_COMPONENTS atomic)
endif()
find_package(fmt 10 CONFIG REQUIRED)
find_package(ftxui CONFIG REQUIRED)
find_package(outcome CONFIG REQUIRED)
find_package(llfio CONFIG REQUIRED)
find_package(concrete 0.0 CONFIG REQUIRED)
find_package(deeppack 0.1 CONFIG REQUIRED)
find_package(Boost 1.82 REQUIRED COMPONENTS ${DLOG_REQUIRED_BOOST_COMPONENTS})
find_package(Catch2 CONFIG)
set_package_properties(Catch2 PROPERTIES
TYPE OPTIONAL
PURPOSE "Allows to build the test suite"
)
cmake_dependent_option(BUILD_TESTING "Build the documentation using sphinx" ON Catch2_FOUND OFF)
find_package(Sphinx)
set_package_properties(Sphinx PROPERTIES
TYPE OPTIONAL
PURPOSE "Allows to build the documentation"
)
cmake_dependent_option(BUILD_DOCS "Build the documentation using sphinx" ON Sphinx_FOUND OFF)
########################################################################
# warning configuration
include(CompilerWarnings)
########################################################################
# additional compiler options
set(CMAKE_CXX_EXTENSIONS OFF CACHE STRING "" FORCE)
add_library(compiler_settings INTERFACE)
add_library(Deeplex::deeplog_compiler_settings ALIAS compiler_settings)
set_target_properties(compiler_settings PROPERTIES
EXPORT_NAME deeplog_compiler_settings
)
target_compile_features(compiler_settings INTERFACE cxx_std_20)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(compiler_settings INTERFACE
/utf-8 # all sources are utf-8 encoded
/Zc:__cplusplus # correctly define the __cplusplus macro
)
endif()
########################################################################
# library
add_subdirectory(libs/deeplog)
add_subdirectory(libs/deeplog_tui)
########################################################################
# cli projects
add_subdirectory(apps/deeplog-cli)
########################################################################
# examples
if (BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
########################################################################
# docs
if (BUILD_DOCS)
add_subdirectory(docs)
endif()
########################################################################
# cmake install
install(TARGETS deeplog deeplog_tui compiler_settings EXPORT deeplog-targets)
install(EXPORT deeplog-targets
NAMESPACE Deeplex::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/deeplog"
)
export(EXPORT deeplog-targets NAMESPACE Deeplex::)
# note that you need to configure with -DCMAKE_EXPORT_PACKAGE_REGISTRY=ON
# for this to have any effect at all
export(PACKAGE deeplog)
configure_package_config_file(tools/deeplog-config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/deeplog-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/deeplog"
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/deeplog-config-version.cmake"
COMPATIBILITY SameMinorVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/deeplog-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/deeplog-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/deeplog"
)
########################################################################
feature_summary(WHAT PACKAGES_FOUND PACKAGES_NOT_FOUND)