-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
111 lines (97 loc) · 3.85 KB
/
CMakeLists.txt
File metadata and controls
111 lines (97 loc) · 3.85 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
cmake_minimum_required(VERSION 3.14)
project(MPSC_Project CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(CMAKE_BUILD_TYPE MATCHES "Release")
set(DEFAULT_RELEASE_OPTS "$<$<CXX_COMPILER_ID:MSVC>:/O2 /Ob2>$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-O3>")
endif()
include(FetchContent)
# Google Benchmark
FetchContent_Declare(
googlebenchmark
URL https://github.com/google/benchmark/archive/refs/tags/v1.8.3.zip
FIND_PACKAGE_ARGS NAMES benchmark CONFIG
)
set(BENCHMARK_ENABLE_TESTING OFF)
FetchContent_MakeAvailable(googlebenchmark)
# Google Test
enable_testing()
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
FIND_PACKAGE_ARGS NAMES GTest CONFIG
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
# HdrHistogram
FetchContent_Declare(
hdrhistogram
URL https://github.com/HdrHistogram/HdrHistogram_c/archive/refs/tags/0.11.8.zip
)
set(HDR_HISTOGRAM_BUILD_PROGRAMS OFF CACHE BOOL "" FORCE)
set(HDR_HISTOGRAM_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(HDR_LOG_REQUIRED "DISABLED" CACHE STRING "" FORCE)
FetchContent_MakeAvailable(hdrhistogram)
find_package(Threads REQUIRED)
set(COMMON_TARGET_PROPERTIES
PRIVATE
${DEFAULT_RELEASE_OPTS}
$<$<CXX_COMPILER_ID:MSVC>:/EHsc>
)
#BENCHMARK
add_executable(mpsc_bench_throughput benchmarks/bench_throughput.cpp)
target_include_directories(mpsc_bench_throughput
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(mpsc_bench_throughput
PRIVATE
benchmark::benchmark_main
Threads::Threads
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:atomic>
)
target_compile_options(mpsc_bench_throughput ${COMMON_TARGET_PROPERTIES})
add_executable(mpsc_bench_latency benchmarks/bench_latency.cpp)
target_include_directories(mpsc_bench_latency
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}
${hdrhistogram_SOURCE_DIR}/src
)
target_link_libraries(mpsc_bench_latency
PRIVATE
benchmark::benchmark_main
hdr_histogram_static
Threads::Threads
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:atomic>
)
target_compile_options(mpsc_bench_latency ${COMMON_TARGET_PROPERTIES})
add_executable(mpsc_bench_linearizable benchmarks/bench_linearizable.cpp)
target_include_directories(mpsc_bench_linearizable
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(mpsc_bench_linearizable
PRIVATE
benchmark::benchmark_main
Threads::Threads
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:atomic>
)
target_compile_options(mpsc_bench_linearizable ${COMMON_TARGET_PROPERTIES})
# TEST
add_executable(mpsc_tests tests/test_MPSC.cpp)
target_include_directories(mpsc_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(mpsc_tests PRIVATE GTest::gtest_main GTest::gmock Threads::Threads $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:atomic>)
include(GoogleTest)
gtest_discover_tests(mpsc_tests)
#EXAMPLE
add_executable(mpsc_log_system_example examples/log_system.cpp)
target_include_directories(mpsc_log_system_example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(mpsc_log_system_example PRIVATE Threads::Threads $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:atomic>)
target_compile_options(mpsc_log_system_example ${COMMON_TARGET_PROPERTIES})
add_executable(mpsc_command_dispatcher_example examples/command_dispatcher.cpp)
target_include_directories(mpsc_command_dispatcher_example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(mpsc_command_dispatcher_example PRIVATE Threads::Threads $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:atomic>)
target_compile_options(mpsc_command_dispatcher_example ${COMMON_TARGET_PROPERTIES})