forked from CharlesFrasch/cppcon2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
70 lines (52 loc) · 1.81 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
cmake_minimum_required(VERSION 3.22)
project(frasch_spsc_cppcon2023)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED true)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(Boost REQUIRED)
include(FetchContent)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main)
FetchContent_Declare(googlebenchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG main # need main for benchmark::benchmark
)
set(BENCHMARK_ENABLE_TESTING OFF)
FetchContent_MakeAvailable(
googletest
googlebenchmark
)
add_compile_options(-Wall -Werror -Wextra -Wconversion)
add_compile_options(-Wno-unused-parameter)
function(add_fifo fifo)
add_executable(${fifo} ${CMAKE_SOURCE_DIR}/${fifo}.cpp)
add_executable(${fifo}.tsan ${CMAKE_SOURCE_DIR}/${fifo}.cpp)
target_compile_options(${fifo}.tsan PRIVATE -fsanitize=thread)
target_link_options(${fifo}.tsan PRIVATE -fsanitize=thread)
endfunction()
add_fifo(fifo1)
add_fifo(fifo2)
add_fifo(fifo3)
add_fifo(fifo4)
add_fifo(fifo4a)
add_fifo(fifo4b)
add_fifo(fifo5)
add_fifo(fifo5a)
add_fifo(boost_lockfree)
target_link_libraries(boost_lockfree PRIVATE Boost::boost)
target_link_libraries(boost_lockfree.tsan PRIVATE Boost::boost)
add_fifo(rigtorp)
add_fifo(mutex)
add_fifo(tryLock)
include(GoogleTest)
enable_testing()
add_executable(unitTests unitTests.cpp)
target_link_libraries(unitTests PRIVATE GTest::gtest_main)
target_compile_options(unitTests PRIVATE -fsanitize=undefined -fsanitize=address)
target_link_options(unitTests PRIVATE -fsanitize=undefined -fsanitize=address)
gtest_add_tests(TARGET unitTests)
add_executable(bench bench.cpp)
target_link_libraries(bench PRIVATE benchmark::benchmark)
add_executable(bench_all bench_all.cpp)
target_link_libraries(bench_all PRIVATE Boost::boost)