-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
132 lines (114 loc) · 3.46 KB
/
Copy pathCMakeLists.txt
File metadata and controls
132 lines (114 loc) · 3.46 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
cmake_minimum_required(VERSION 3.15)
project(kickmsg LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Find conan-generated CMake package configs in the build directory
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_BINARY_DIR})
option(BUILD_UNIT_TESTS "Build unit tests" OFF)
option(BUILD_EXAMPLES "Build examples" OFF)
option(BUILD_BENCHMARKS "Build benchmarks (requires Google Benchmark)" OFF)
option(ENABLE_TSAN "Enable ThreadSanitizer" OFF)
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer" OFF)
option(ENABLE_WERROR "Treat warnings as errors (CI)" OFF)
if(NOT MSVC)
add_compile_options(-Wall -Wextra)
if(ENABLE_WERROR)
add_compile_options(-Werror)
endif()
endif()
# TSAN cannot share a process with ASAN/UBSAN runtimes; ASAN+UBSAN together is fine.
if(ENABLE_TSAN AND (ENABLE_ASAN OR ENABLE_UBSAN))
message(FATAL_ERROR "ENABLE_TSAN cannot be combined with ENABLE_ASAN or ENABLE_UBSAN")
endif()
if(ENABLE_TSAN)
add_compile_options(-fsanitize=thread -g)
add_link_options(-fsanitize=thread)
endif()
if(ENABLE_ASAN)
add_compile_options(-fsanitize=address -g)
add_link_options(-fsanitize=address)
endif()
if(ENABLE_UBSAN)
add_compile_options(-fsanitize=undefined -g)
add_link_options(-fsanitize=undefined)
endif()
# --- Platform-specific OS sources ---
if(WIN32)
set(OS_SOURCES
src/os/windows/Time.cc
src/os/windows/Futex.cc
src/os/windows/SharedMemory.cc
src/os/windows/Process.cc
)
set(OS_LIBRARIES synchronization)
else()
# Linux and macOS share most of the POSIX OS layer; only sleep(),
# create(), and the futex backend diverge.
set(OS_SOURCES
src/os/posix/Time.cc
src/os/posix/SharedMemory.cc
src/os/posix/Process.cc
)
if(APPLE)
list(APPEND OS_SOURCES
src/os/darwin/Time.cc
src/os/darwin/SharedMemory.cc
src/os/darwin/Futex.cc
src/os/darwin/Process.cc
)
set(OS_LIBRARIES pthread)
else()
list(APPEND OS_SOURCES
src/os/linux/Time.cc
src/os/linux/SharedMemory.cc
src/os/linux/Futex.cc
src/os/linux/Process.cc
)
set(OS_LIBRARIES rt pthread)
endif()
endif()
# --- Library ---
add_library(kickmsg STATIC
src/types.cc
src/Hash.cc
src/Naming.cc
src/Publisher.cc
src/Subscriber.cc
src/Region.cc
src/Registry.cc
src/Node.cc
${OS_SOURCES}
)
target_include_directories(kickmsg
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include/kickmsg
)
target_link_libraries(kickmsg PUBLIC ${OS_LIBRARIES})
# --- Version header (generated from git: cmake/version.cmake) ---
include(cmake/version.cmake)
# --- Install, pkg-config, find_package ---
include(cmake/install.cmake)
# --- Tests ---
if(BUILD_UNIT_TESTS)
find_package(GTest REQUIRED CONFIG)
find_package(argparse REQUIRED CONFIG)
enable_testing()
add_subdirectory(tests)
endif()
# --- Examples ---
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
# --- Benchmarks ---
if(BUILD_BENCHMARKS)
find_package(benchmark REQUIRED CONFIG)
add_subdirectory(benchmarks)
endif()
# --- Python bindings (built only when invoked via scikit-build-core) ---
if(SKBUILD)
add_subdirectory(py_bindings)
endif()