-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
50 lines (37 loc) · 1.55 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
cmake_minimum_required(VERSION 3.9.1)
project(Ccs VERSION 0.9.20 DESCRIPTION "CCS configuration library")
option(COVERAGE "Build with code coverage enabled" OFF)
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION}")
message(STATUS "Coverage: ${COVERAGE}")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# All the sanitizer flags in one place
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fsanitize=address")
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fsanitize=undefined")
else ()
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -static-libasan")
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -static-libubsan")
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fsanitize=address")
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fsanitize=signed-integer-overflow")
set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fsanitize=bounds-strict -fsanitize=undefined")
endif ()
# Common flags shared across all builds
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -g")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-mismatched-tags")
endif()
# Debug flags
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${SANITIZE_FLAGS}")
include(CTest)
include(GNUInstallDirs)
# Enable libtooling support
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# External libraries/dependencies
add_subdirectory(external/googletest EXCLUDE_FROM_ALL)
include_directories(api src)
link_directories(${PROJECT_BINARY_DIR}/lib)
add_subdirectory(src)
enable_testing()
add_subdirectory(test)