-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
89 lines (75 loc) · 2.2 KB
/
CMakeLists.txt
File metadata and controls
89 lines (75 loc) · 2.2 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
cmake_minimum_required(VERSION 3.20)
project(SwiftChannel LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Compiler options
include(cmake/compiler_options.cmake)
# Define the compiled library (receiver + infrastructure)
add_library(swiftchannel STATIC
src/receiver/receiver.cpp
src/receiver/dispatch.cpp
src/sender/channel_impl.cpp
src/ipc/shared_memory.cpp
src/ipc/handshake.cpp
src/diagnostics/stats.cpp
)
target_include_directories(swiftchannel
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Platform-specific sources
if (WIN32)
target_sources(swiftchannel PRIVATE
src/platform/windows/shm_win.cpp
src/platform/windows/pipe_win.cpp
)
else()
target_sources(swiftchannel PRIVATE
src/platform/posix/shm_posix.cpp
src/platform/posix/socket_posix.cpp
)
endif()
# Compiler definitions
target_compile_definitions(swiftchannel PUBLIC
SWIFTCHANNEL_VERSION_MAJOR=1
SWIFTCHANNEL_VERSION_MINOR=0
SWIFTCHANNEL_VERSION_PATCH=0
)
# Enable testing
option(SWIFTCHANNEL_BUILD_TESTS "Build tests" ON)
option(SWIFTCHANNEL_BUILD_EXAMPLES "Build examples" ON)
if(SWIFTCHANNEL_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
if(SWIFTCHANNEL_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
# Installation
install(TARGETS swiftchannel
EXPORT SwiftChannelTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(DIRECTORY include/swiftchannel
DESTINATION include
)
install(EXPORT SwiftChannelTargets
FILE SwiftChannelTargets.cmake
NAMESPACE SwiftChannel::
DESTINATION lib/cmake/SwiftChannel
)
# Generate config file
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/SwiftChannelConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SwiftChannelConfig.cmake
INSTALL_DESTINATION lib/cmake/SwiftChannel
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/SwiftChannelConfig.cmake
DESTINATION lib/cmake/SwiftChannel
)