-
Notifications
You must be signed in to change notification settings - Fork 20
/
CMakeLists.txt
71 lines (61 loc) · 2.02 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
cmake_minimum_required (VERSION 2.8)
project (constexpr-all-the-things)
# Includes for this project
include_directories ("${PROJECT_SOURCE_DIR}/src/include")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Default C++ standard: C++1z
if(CXX_STD)
else()
set(CXX_STD 1z)
endif()
# Use local libc++
if($ENV{USE_LOCAL_LIBCXX})
message("Using local libc++ (assumed in /usr/local)")
add_compile_options(-nostdinc++)
add_compile_options(-I/usr/local/include/c++/v1)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi -L/usr/local/lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/usr/local/lib")
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(MY_CXX_FLAGS_LIST
)
string(REPLACE ";" " " MY_CXX_FLAGS "${MY_CXX_FLAGS_LIST}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_FLAGS}")
else()
set(MY_CXX_FLAGS_LIST
-ftemplate-backtrace-limit=0
-ffunction-sections
-Wall -Wextra -Werror -pedantic-errors
-Wno-gnu-string-literal-operator-template
-Wcast-align
-Wcast-qual
-Wctor-dtor-privacy
-Wdisabled-optimization
-Wformat=2
-Winit-self
-Wmissing-include-dirs
-Wold-style-cast
-Woverloaded-virtual
-Wredundant-decls
-Wshadow
-Wsign-conversion
-Wsign-promo
-Wstrict-overflow=5
-Wswitch-default
-Wundef
)
string(REPLACE ";" " " MY_CXX_FLAGS "${MY_CXX_FLAGS_LIST}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CXX_STD} ${MY_CXX_FLAGS}")
# Debug/Release
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fno-inline -g3 -fstack-protector-all")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g0 -march=native -mtune=native -DNDEBUG")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
endif()
# Clang/GCC specifics
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(SAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined,integer -fno-omit-frame-pointer -fno-sanitize=unsigned-integer-overflow")
endif()
elseif(CMAKE_COMPILER_IS_GNUCXX)
endif()
add_subdirectory (src/test)