-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
66 lines (57 loc) · 1.68 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
cmake_minimum_required(VERSION 3.28)
project(modules_benchmark CXX)
find_package(OpenSSL REQUIRED)
# Use modules?
set(USE_MODULES ON)
# Always use libc++
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-stdlib=libc++ -ftime-trace)
add_link_options(-stdlib=libc++)
# Disable module scanning
if (USE_MODULES)
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
else()
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
endif()
# Build the stdlib module
function (add_stdlib_module NAME)
add_library(${NAME})
target_sources(${NAME} PUBLIC
FILE_SET CXX_MODULES FILES
stdlib/std.cppm
stdlib/std.compat.cppm
)
target_compile_features(${NAME} PUBLIC cxx_std_23)
target_compile_options(${NAME} PRIVATE -Wno-reserved-module-identifier)
endfunction()
if (USE_MODULES)
# Find the Asio package containing the function to build the module
find_package(Asio REQUIRED)
# Build the stdlib module
add_stdlib_module(stdlib)
# Build the asio module
add_asio_module(asio)
else()
# Asio interface library
add_library(asio INTERFACE)
target_include_directories(asio INTERFACE asio-module/include)
target_compile_features(asio INTERFACE cxx_std_23)
target_link_libraries(asio INTERFACE OpenSSL::SSL OpenSSL::Crypto)
endif()
# Executable
add_executable(server main.cpp
main2.cpp
main3.cpp
main4.cpp
main5.cpp
main6.cpp
main7.cpp
)
target_compile_features(server PRIVATE cxx_std_23)
if (USE_MODULES)
target_link_libraries(server PRIVATE stdlib asio)
target_compile_definitions(server PRIVATE USE_MODULES)
target_compile_options(server PRIVATE -Wno-deprecated-declarations)
else()
target_link_libraries(server PRIVATE asio)
endif()