-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
55 lines (49 loc) · 2.11 KB
/
CMakeLists.txt
File metadata and controls
55 lines (49 loc) · 2.11 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
cmake_minimum_required(VERSION 3.18)
project(WorkStealingQueue VERSION 1.0 LANGUAGES CXX)
# ---------------------------------------------------------------------------
# C++ standard
# ---------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# ---------------------------------------------------------------------------
# Build type default
# ---------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to Release")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()
# ---------------------------------------------------------------------------
# Header-only interface target
# ---------------------------------------------------------------------------
add_library(wsq INTERFACE)
target_include_directories(wsq INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(wsq INTERFACE cxx_std_20)
# ---------------------------------------------------------------------------
# Compiler warnings / optimisation flags
# ---------------------------------------------------------------------------
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
target_compile_options(wsq INTERFACE
$<$<CONFIG:Release>:-O3 -march=native>
$<$<CONFIG:Debug>:-O0 -g -fsanitize=address,undefined>
)
target_link_options(wsq INTERFACE
$<$<CONFIG:Debug>:-fsanitize=address,undefined>
)
elseif(MSVC)
target_compile_options(wsq INTERFACE
$<$<CONFIG:Release>:/O2>
$<$<CONFIG:Debug>:/Od /Zi>
)
endif()
# ---------------------------------------------------------------------------
# Threading
# ---------------------------------------------------------------------------
find_package(Threads REQUIRED)
target_link_libraries(wsq INTERFACE Threads::Threads)
# ---------------------------------------------------------------------------
# Sub-projects
# ---------------------------------------------------------------------------
enable_testing()
add_subdirectory(unittests)
add_subdirectory(examples)