-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
70 lines (56 loc) · 2.27 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.13.4)
project(cogle_utils)
set(CMAKE_CXX_STANDARD 17)
set(CUSTOM_COMPILER_FLAGS -Wall -Wextra -Wconversion -Werror -Wshadow -Wundef)
set(CUSTOM_LINKER_FLAGS "")
###################################
# #
# Configuration Options #
# #
###################################
option(WITH_TSAN "Build with TSAN" OFF)
option(WITH_ASAN "Build with ASAN" OFF)
option(WITH_UBSAN "Build with UBSAN" OFF)
option(WITH_GCOV "Build with GCOV Code Coverage" OFF)
option(WITH_TESTS "Build with Unit Tests" OFF)
option(WITH_EXAMPLES "Build with Examples" OFF)
message(STATUS "Build WITH_TSAN: " ${WITH_TSAN})
message(STATUS "BUILD WITH_ASAN: " ${WITH_ASAN})
message(STATUS "BUILD WITH_UBSAN: " ${WITH_UBSAN})
message(STATUS "BUILD WITH_GCOV: " ${WITH_GCOV})
message(STATUS "BUILD WITH_TESTS: " ${WITH_TESTS})
message(STATUS "BUILD WITH_EXAMPLES: " ${WITH_EXAMPLES})
if (WITH_ASAN AND WITH_TSAN)
message(FATAL_ERROR "Unable to build both ASAN and TSAN together")
endif(WITH_ASAN AND WITH_TSAN)
if(WITH_ASAN)
set(CUSTOM_COMPILER_FLAGS ${CUSTOM_COMPILER_FLAGS} -fsanitize=address)
set(CUSTOM_LINKER_FLAGS ${CUSTOM_LINKER_FLAGS} -fsanitize=address)
endif(WITH_ASAN)
if(WITH_TSAN)
set(CUSTOM_COMPILER_FLAGS ${CUSTOM_COMPILER_FLAGS} -fsanitize=thread)
set(CUSTOM_LINKER_FLAGS ${CUSTOM_LINKER_FLAGS} -fsanitize=thread)
endif(WITH_TSAN)
if(WITH_UBSAN)
set(CUSTOM_COMPILER_FLAGS ${CUSTOM_COMPILER_FLAGS} -fsanitize=undefined)
set(CUSTOM_LINKER_FLAGS ${CUSTOM_LINKER_FLAGS} -fsanitize=undefined)
endif(WITH_UBSAN)
if(WITH_GCOV)
set(CUSTOM_COMPILER_FLAGS ${CUSTOM_COMPILER_FLAGS} -O0 -g -fprofile-arcs -ftest-coverage)
set(CUSTOM_LINKER_FLAGS ${CUSTOM_LINKER_FLAGS} --coverage)
endif(WITH_GCOV)
SET(THIRD_PARTY_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/third_party)
set(LIB_TARGET cogle_utils)
add_library(${LIB_TARGET} INTERFACE)
add_library(${PROJECT_NAME}::lib ALIAS ${LIB_TARGET})
target_include_directories(${LIB_TARGET} INTERFACE
include/
)
if(WITH_EXAMPLES)
add_subdirectory(examples)
endif(WITH_EXAMPLES)
if (WITH_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/Catch2)
enable_testing()
add_subdirectory(tests/)
endif(WITH_TESTS)