-
Notifications
You must be signed in to change notification settings - Fork 27
/
CMakeLists.txt
191 lines (154 loc) · 6.46 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Copyright (c) 2023 Klemens D. Morgenstern
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# 3.12 for cxx_std_20
cmake_minimum_required(VERSION 3.12...3.20)
if(BOOST_SUPERPROJECT_VERSION)
set(BOOST_COBALT_VERSION ${BOOST_SUPERPROJECT_VERSION})
endif()
project(boost_cobalt VERSION "${BOOST_COBALT_VERSION}" LANGUAGES CXX)
include(cmake/CheckRequirements.cmake)
if (NOT BOOST_COBALT_REQUIREMENTS_MATCHED)
return()
endif()
set(BOOST_COBALT_IS_ROOT OFF)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(BOOST_COBALT_IS_ROOT ON)
endif()
option(BOOST_COBALT_USE_BOOST_CONTAINER "Boost.Cobalt: Use boost.container instead of std::pmr" ${BOOST_COBALT_SHOULD_USE_CONTAINER})
if (NOT BOOST_COBALT_IS_ROOT)
# Generated by `boostdep --cmake cobalt`
# Copyright 2020, 2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
add_library(boost_cobalt
src/detail/exception.cpp
src/detail/util.cpp
src/channel.cpp
src/error.cpp
src/main.cpp
src/this_thread.cpp
src/thread.cpp
)
add_library(Boost::cobalt ALIAS boost_cobalt)
target_include_directories(boost_cobalt PUBLIC include)
target_link_libraries(boost_cobalt
PUBLIC
Boost::asio
Boost::callable_traits
Boost::circular_buffer
Boost::config
Boost::core
Boost::intrusive
Boost::mp11
Boost::preprocessor
Boost::smart_ptr
Boost::system
Boost::throw_exception
Boost::variant2
)
target_compile_definitions(boost_cobalt
PUBLIC BOOST_COBALT_NO_LIB=1
PRIVATE BOOST_COBALT_SOURCE=1
)
target_compile_features(boost_cobalt PUBLIC cxx_std_20)
if (MSVC)
target_compile_definitions(boost_cobalt PUBLIC _WIN32_WINNT=0x0601)
endif()
if (BOOST_COBALT_USE_BOOST_CONTAINER)
target_link_libraries(boost_cobalt PUBLIC Boost::container)
target_compile_definitions(boost_cobalt PUBLIC BOOST_COBALT_USE_BOOST_CONTAINER_PMR=1 )
endif()
if(BUILD_SHARED_LIBS)
target_compile_definitions(boost_cobalt PUBLIC BOOST_COBALT_DYN_LINK)
else()
target_compile_definitions(boost_cobalt PUBLIC BOOST_COBALT_STATIC_LINK)
endif()
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()
else()
project(boost_cobalt VERSION "${BOOST_COBALT_VERSION}" LANGUAGES CXX)
if(BOOST_SUPERPROJECT_VERSION)
set(BOOST_COBALT_SHOULD_BE_INLINE ON)
else()
set(BOOST_COBALT_SHOULD_BE_INLINE OFF)
endif()
option(BOOST_COBALT_BUILD_INLINE "Configure as if part of the boost source tree" ${BOOST_COBALT_SHOULD_BE_INLINE})
file(GLOB_RECURSE ADOC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.adoc)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html
COMMAND asciidoctor ${CMAKE_CURRENT_SOURCE_DIR}/doc/index.adoc --require asciidoctor-diagram --require asciidoctor-multipage -b multipage_html5 -a generate-diagram -o ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html
DEPENDS ${ADOC_FILES})
add_custom_target(boost_cobalt_doc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html)
if(BOOST_COBALT_IS_ROOT)
#include(CTest)
endif()
if(NOT BOOST_SUPERPROJECT_VERSION)
option(BOOST_COBALT_INSTALL "Install boost::cobalt files" ON)
option(BOOST_COBALT_BUILD_TESTS "Build boost::cobalt tests" ${BUILD_TESTING})
option(BOOST_COBALT_BUILD_EXAMPLES "Build boost::cobalt examples" ${BOOST_COBALT_IS_ROOT})
option(BOOST_COBALT_BUILD_BENCHMARKS "Build boost::cobalt benchmarks" OFF)
else()
set(BOOST_COBALT_BUILD_TESTS ${BUILD_TESTING})
endif()
if(BOOST_COBALT_IS_ROOT AND BOOST_COBALT_BUILD_INLINE)
#
# Building inside Boost tree, but as a separate project e.g. on Travis or
# other CI, or when producing Visual Studio Solution and Projects.
set(BOOST_INCLUDE_LIBRARIES cobalt)
set(BOOST_EXCLUDE_LIBRARIES cobalt)
set(CMAKE_FOLDER _deps)
add_subdirectory(../.. _deps/boost EXCLUDE_FROM_ALL)
unset(CMAKE_FOLDER)
endif()
if (NOT BOOST_COBALT_BUILD_INLINE)
find_package(Threads REQUIRED)
# Boost 1.82 is the first with a Boost.ASIO with necessary support
find_package(Boost REQUIRED COMPONENTS system OPTIONAL_COMPONENTS json context url unit_test_framework)
if (BOOST_COBALT_USE_BOOST_CONTAINER)
find_package(Boost REQUIRED container)
endif()
endif()
add_library(boost_cobalt
src/detail/exception.cpp
src/detail/util.cpp
src/error.cpp
src/channel.cpp
src/main.cpp
src/this_thread.cpp
src/thread.cpp)
target_include_directories(boost_cobalt PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(boost_cobalt PUBLIC
Boost::system
Threads::Threads)
target_compile_definitions(boost_cobalt PRIVATE BOOST_COBALT_SOURCE=1 )
if (BOOST_COBALT_USE_BOOST_CONTAINER)
target_link_libraries(boost_cobalt PUBLIC Boost::container)
target_compile_definitions(boost_cobalt PUBLIC BOOST_COBALT_USE_BOOST_CONTAINER_PMR=1 )
endif()
target_compile_features(boost_cobalt PUBLIC cxx_std_20)
add_library(Boost::cobalt ALIAS boost_cobalt)
if(BUILD_SHARED_LIBS)
target_compile_definitions(boost_cobalt PUBLIC BOOST_COBALT_DYN_LINK=1)
else()
target_compile_definitions(boost_cobalt PUBLIC BOOST_COBALT_STATIC_LINK=1)
endif()
if(BOOST_COBALT_INSTALL AND NOT BOOST_SUPERPROJECT_VERSION)
install(TARGETS boost_cobalt
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
endif()
if(BOOST_COBALT_BUILD_TESTS)
add_subdirectory(test)
endif()
if(BOOST_COBALT_BUILD_EXAMPLES)
add_subdirectory(example)
set_target_properties(boost_cobalt PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
if(BOOST_COBALT_BUILD_BENCHMARKS)
add_subdirectory(bench)
endif()
endif()