-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
92 lines (70 loc) · 2.51 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
cmake_minimum_required(VERSION 3.5)
project(SimpleLogger VERSION 0.3.26 LANGUAGES CXX)
# === Build type (default: RelWithDebInfo, O2) ===========
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo"
CACHE STRING
"Options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
message(STATUS "Build type is not given, use default.")
endif ()
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
set(ROOT_SRC ${PROJECT_SOURCE_DIR}/src)
set(TEST_DIR ${PROJECT_SOURCE_DIR}/tests)
set(EXAMPLE_DIR ${PROJECT_SOURCE_DIR}/example)
set(LIBDL dl)
# Includes
include_directories(BEFORE ./)
include_directories(BEFORE ${PROJECT_SOURCE_DIR}/src)
include_directories(BEFORE ${PROJECT_SOURCE_DIR}/tests)
# Compiler flags
if (NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
if (NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif ()
endif()
if (ADDRESS_SANITIZER GREATER 0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
message(STATUS "---- ADDRESS SANITIZER IS ON ----")
endif()
if (THREAD_SANITIZER GREATER 0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
add_definitions(-DSUPPRESS_TSAN_FALSE_ALARMS=1)
message(STATUS "---- THREAD SANITIZER IS ON ----")
endif()
if (LEAK_SANITIZER GREATER 0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
message(STATUS "---- LEAK SANITIZER IS ON ----")
endif()
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5045 /wd4571 /wd4774 /wd4820 /wd5039 /wd4626 /wd4625 /wd5026 /wd5027 /wd4623 /wd4996 /W3")
message(STATUS "---- WIN32 ----")
endif()
# === Program flags ===
if ( (TESTSUITE_NO_COLOR GREATER 0) OR (WIN32) )
add_definitions(-DTESTSUITE_NO_COLOR=1)
add_definitions(-DLOGGER_NO_COLOR=1)
message(STATUS "---- NO ANSI COLOR ----")
endif()
if (APPLE)
set(OPEN_MEMSTREAM ${COMMON_SRC}/open_memstream.c)
endif ()
# === Test ===
set(LOGGER_TEST
${TEST_DIR}/logger_test.cc
${ROOT_SRC}/logger.cc)
add_executable(logger_test ${LOGGER_TEST})
# === Example ===
set(BASIC_EXAMPLE
${EXAMPLE_DIR}/basic_example.cc
${ROOT_SRC}/logger.cc)
add_executable(basic_example ${BASIC_EXAMPLE})
set(CRASH_EXAMPLE
${EXAMPLE_DIR}/crash_example.cc
${ROOT_SRC}/logger.cc)
add_executable(crash_example ${CRASH_EXAMPLE})