@@ -2,26 +2,27 @@ cmake_minimum_required(VERSION 3.28...3.31)
2
2
3
3
include (cmake/prelude.cmake)
4
4
5
- project (asio
6
- VERSION 1.34.0.1
7
- DESCRIPTION "Asio C++ Library"
8
- HOMEPAGE_URL "http://think-async.com/Asio/"
9
- LANGUAGES CXX
5
+ project (
6
+ asio
7
+ VERSION 1.34.0.1
8
+ DESCRIPTION "Asio C++ Library"
9
+ HOMEPAGE_URL "http://think-async.com/Asio/"
10
+ LANGUAGES CXX
10
11
)
11
12
12
13
include (cmake/variables .cmake)
13
14
14
15
if (PROJECT_IS_TOP_LEVEL)
15
- include (CheckCXXSymbolExists)
16
- check_cxx_symbol_exists(snprintf cstdio ASIO_HAS_SNPRINTF)
17
- check_cxx_symbol_exists(sprintf_s cstdio ASIO_HAS_SECURE_RTL)
16
+ include (CheckCXXSymbolExists)
17
+ check_cxx_symbol_exists(snprintf cstdio ASIO_HAS_SNPRINTF)
18
+ check_cxx_symbol_exists(sprintf_s cstdio ASIO_HAS_SECURE_RTL)
18
19
endif ()
19
20
20
21
set (CPPdefinitions ASIO_NO_DEPRECATED ASIO_DISABLE_BOOST_CONTEXT_FIBER)
21
22
if (ASIO_HAS_SECURE_RTL)
22
- list (APPEND CPPdefinitions ASIO_HAS_SECURE_RTL)
23
+ list (APPEND CPPdefinitions ASIO_HAS_SECURE_RTL)
23
24
elseif (ASIO_HAS_SNPRINTF)
24
- list (APPEND CPPdefinitions ASIO_HAS_SNPRINTF)
25
+ list (APPEND CPPdefinitions ASIO_HAS_SNPRINTF)
25
26
endif ()
26
27
27
28
option (ASIO_SEPARATE_COMPILATION "build asio lib too" ${PROJECT_IS_TOP_LEVEL} )
@@ -34,82 +35,110 @@ find_package(OpenSSL REQUIRED)
34
35
35
36
# ---- Declare library ----
36
37
37
- file (GLOB_RECURSE _asio_implementation "include/asio/*/*.hpp" "include/asio/*.ipp" )
38
+ file (
39
+ GLOB_RECURSE _asio_implementation
40
+ "include/asio/*/*.hpp"
41
+ "include/asio/*.ipp"
42
+ )
38
43
list (FILTER _asio_implementation EXCLUDE REGEX [=[.*/experimental/.*]=])
39
44
40
45
# asio interface library
41
46
add_library (asio_header INTERFACE )
42
47
add_library (asio::asio_header ALIAS asio_header)
43
- target_sources (asio_header INTERFACE FILE_SET HEADERS BASE_DIRS include FILES ${_asio_implementation} )
48
+ target_sources (
49
+ asio_header
50
+ INTERFACE FILE_SET HEADERS BASE_DIRS include FILES ${_asio_implementation}
51
+ )
44
52
target_link_libraries (asio_header INTERFACE OpenSSL::SSL OpenSSL::Crypto)
45
53
46
54
target_compile_definitions (asio_header INTERFACE ${CPPdefinitions} )
47
55
target_compile_features (
48
- asio_header INTERFACE "$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>"
49
- "$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
56
+ asio_header
57
+ INTERFACE
58
+ "$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>"
59
+ "$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
50
60
)
51
61
target_link_libraries (asio_header INTERFACE Threads::Threads)
52
62
53
63
if (ASIO_SEPARATE_COMPILATION)
54
- set (_libasio_SOURCES src/asio.cpp)
55
-
56
- if (OpenSSL_FOUND)
57
- list (APPEND _libasio_SOURCES src/asio_ssl.cpp)
58
- endif ()
59
-
60
- set (CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL} )
61
-
62
- file (GLOB_RECURSE _asio_headers "include/asio/*.hpp" )
63
- list (FILTER _asio_headers EXCLUDE REGEX [=[.*/experimental/.*\.hpp]=])
64
- list (FILTER _asio_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=])
65
-
66
- # FIXME: some header in include/asio/detail fails CMAKE_VERIFY_INTERFACE_HEADER_SETS!
67
- # NOTE: we need them installed, but we used them install with asio_header INTERFACE! CK
68
- set (_public_headers include /asio.hpp ${_asio_headers} )
69
- list (FILTER _public_headers EXCLUDE REGEX [=[.*/detail/.*\.hpp]=])
70
- list (FILTER _public_headers EXCLUDE REGEX [=[.*/impl/.*\.hpp]=])
71
- list (FILTER _public_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=])
72
- # foreach(header in LISTS ${_public_headers})
73
- # message(INFO "${header}")
74
- # endforeach()
75
-
76
- add_library (asio SHARED ${_libasio_SOURCES} )
77
- add_library (asio::asio ALIAS asio)
78
- target_sources (asio PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS include FILES ${_public_headers} )
79
-
80
- target_compile_definitions (asio PUBLIC ASIO_SEPARATE_COMPILATION ${CPPdefinitions} )
81
- target_link_libraries (asio PUBLIC Threads::Threads)
82
- target_compile_features (
83
- asio INTERFACE "$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>" "$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
84
- )
85
-
86
- if (ASIO_WARNINGS_AS_ERRORS AND ASIO_DEVELOPER_MODE AND UNIX )
87
- target_compile_options (asio PUBLIC -Werror)
88
- endif ()
89
-
90
- if (OpenSSL_FOUND)
91
- target_link_libraries (asio PUBLIC OpenSSL::SSL OpenSSL::Crypto)
92
- endif ()
64
+ set (_libasio_SOURCES src/asio.cpp)
65
+
66
+ if (OpenSSL_FOUND)
67
+ list (APPEND _libasio_SOURCES src/asio_ssl.cpp)
68
+ endif ()
69
+
70
+ set (CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL} )
71
+
72
+ file (GLOB_RECURSE _asio_headers "include/asio/*.hpp" )
73
+ list (FILTER _asio_headers EXCLUDE REGEX [=[.*/experimental/.*\.hpp]=])
74
+ list (FILTER _asio_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=])
75
+
76
+ # FIXME: some header in include/asio/detail fails CMAKE_VERIFY_INTERFACE_HEADER_SETS!
77
+ # NOTE: we need them installed, but we used them install with asio_header INTERFACE! CK
78
+ set (_public_headers include /asio.hpp ${_asio_headers} )
79
+ list (FILTER _public_headers EXCLUDE REGEX [=[.*/detail/.*\.hpp]=])
80
+ list (FILTER _public_headers EXCLUDE REGEX [=[.*/impl/.*\.hpp]=])
81
+ list (FILTER _public_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=])
82
+ # foreach(header in LISTS ${_public_headers})
83
+ # message(INFO "${header}")
84
+ # endforeach()
85
+
86
+ add_library (asio SHARED ${_libasio_SOURCES} )
87
+ add_library (asio::asio ALIAS asio)
88
+ target_sources (
89
+ asio
90
+ PUBLIC
91
+ FILE_SET public_headers
92
+ TYPE HEADERS
93
+ BASE_DIRS include
94
+ FILES ${_public_headers}
95
+ )
96
+
97
+ target_compile_definitions (
98
+ asio
99
+ PUBLIC ASIO_SEPARATE_COMPILATION ${CPPdefinitions}
100
+ )
101
+ target_link_libraries (asio PUBLIC Threads::Threads)
102
+ target_compile_features (
103
+ asio
104
+ INTERFACE
105
+ "$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>"
106
+ "$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
107
+ )
108
+
109
+ if (ASIO_WARNINGS_AS_ERRORS AND ASIO_DEVELOPER_MODE AND UNIX )
110
+ target_compile_options (asio PUBLIC -Werror)
111
+ endif ()
112
+
113
+ if (OpenSSL_FOUND)
114
+ target_link_libraries (asio PUBLIC OpenSSL::SSL OpenSSL::Crypto)
115
+ endif ()
93
116
endif ()
94
117
95
118
add_subdirectory (src/examples)
96
119
97
120
# ---- Install rules ----
98
121
99
122
if (NOT CMAKE_SKIP_INSTALL_RULES)
100
- include (cmake/AddUninstallTarget.cmake)
101
- include (cmake/install -rules.cmake)
102
- configure_file (asio.pc.cmake asio.pc)
103
- install (FILES ${PROJECT_BINARY_DIR} /asio.pc DESTINATION ${CMAKE_INSTALL_LIBDIR} /pkgconfig)
104
- install (FILES module/asio.cppm DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/asio/module)
123
+ include (cmake/AddUninstallTarget.cmake)
124
+ include (cmake/install -rules.cmake)
125
+ configure_file (asio.pc.cmake asio.pc)
126
+ install (
127
+ FILES ${PROJECT_BINARY_DIR} /asio.pc
128
+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /pkgconfig
129
+ )
130
+ install (
131
+ FILES module/asio.cppm
132
+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/asio/module
133
+ )
105
134
endif ()
106
135
107
136
# ---- Developer mode ----
108
137
109
138
if (NOT ASIO_DEVELOPER_MODE)
110
- return ()
139
+ return ()
111
140
elseif (NOT PROJECT_IS_TOP_LEVEL)
112
- message (AUTHOR_WARNING "Developer mode is intended for developers of asio" )
141
+ message (AUTHOR_WARNING "Developer mode is intended for developers of asio" )
113
142
endif ()
114
143
115
144
include (cmake/dev-mode.cmake)
0 commit comments