-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
63 lines (52 loc) · 1.68 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
cmake_minimum_required(VERSION 3.10.3)
project(raner C CXX)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
#https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html
set(CXX_FLAGS
#https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#Debugging-Options
-g
#https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
-D_FILE_OFFSET_BITS=64
#https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options
-Wall
-Wextra
-Werror
-Wconversion
-Wno-unused-parameter
-Wold-style-cast
-Woverloaded-virtual
-Wpointer-arith
-Wshadow
-Wwrite-strings
#https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#x86-Options
-march=native
#https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#C-Dialect-Options
-std=c++17
#https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options
-rdynamic
-fsanitize=address
)
if(CMAKE_BUILD_BITS EQUAL 32)
list(APPEND CXX_FLAGS "-m32")
endif()
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CXX_FLAGS}")
set(CMAKE_CXX_COMPILER "g++")
#https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
set(CMAKE_CXX_FLAGS_DEBUG "-O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -finline-limit=1000 -DNDEBUG")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
find_package(Glog REQUIRED)
find_package(gflags REQUIRED)
include_directories(${PROJECT_SOURCE_DIR})
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
message(STATUS "CXX_FLAGS = " ${CMAKE_CXX_FLAGS} " " ${CMAKE_CXX_FLAGS_${BUILD_TYPE}})
add_subdirectory(raner)
if(NOT CMAKE_BUILD_NO_EXAMPLES)
add_subdirectory(examples)
endif()
enable_testing()
add_subdirectory(tests)