-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
114 lines (97 loc) · 3.06 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
cmake_minimum_required(VERSION 3.9)
project(
broadcast_queue
VERSION 1.0.0
DESCRIPTION "A single producer multiple consumer broadcast queue for C++11"
LANGUAGES CXX
)
add_library(
${PROJECT_NAME} INTERFACE
broadcast_queue.h
condition_variable_waiting_strategy.h
futex_waiting_strategy.h
semaphore_waiting_strategy.h
bitmap_allocator.h
)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
target_include_directories(${PROJECT_NAME}
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
VERSION
${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
${PROJECT_NAME}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
install(
FILES
broadcast_queue.h
futex_waiting_strategy.h
semaphore_waiting_strategy.h
bitmap_allocator.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
)
install(
EXPORT ${PROJECT_NAME}-targets
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)
if(ENABLE_ASAN)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
if(ENABLE_TSAN)
add_compile_options(-fsanitize=thread)
add_link_options(-fsanitize=thread)
endif()
# testing
if(BUILD_TESTING)
enable_testing()
find_package(GTest)
if(NOT GTest_FOUND)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.13.0.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif()
add_executable(
tests
tests/single_threaded_tests.cpp
tests/multi_threaded_tests.cpp
tests/bitmap_allocator_tests.cpp
)
target_link_libraries(tests PRIVATE GTest::gtest_main broadcast_queue)
target_include_directories(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests)
gtest_discover_tests(tests)
endif()
if(BUILD_BENCHES)
include(FetchContent)
FetchContent_Declare(
concurrentqueue
GIT_REPOSITORY https://github.com/cameron314/concurrentqueue
GIT_TAG master
)
FetchContent_MakeAvailable(concurrentqueue)
add_executable(messages_per_second benches/messages_per_second.cpp)
target_link_libraries(messages_per_second broadcast_queue concurrentqueue)
endif()