-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
107 lines (95 loc) · 3.13 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
cmake_minimum_required(VERSION 3.0)
project(YASER C)
set(PRODUCT_NAME yaser)
set(CMAKE_C_STANDARD 11)
if (CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "DEBUG" OR CMAKE_BUILD_TYPE MATCHES "debug")
message("[YASER] Using yaser debug mode (NOT NDEBUG)")
add_definitions(-DYASER_DEBUG)
endif()
if(TARGET_GROUP STREQUAL test)
include(CTest)
include_directories(external/uthash/src)
add_subdirectory(src)
add_subdirectory(external)
add_subdirectory(test)
else()
add_compile_options(
-std=c11
### WARNINGS
# Standrad GCC warnings: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
-Wall
-Werror
-pedantic
-Wextra
-Wunused
-Wno-unused-function
-Wno-unused-parameter
-Wshadow
-Wcast-align
-Wconversion
-Wdouble-promotion
-Wstack-protector
-Wredundant-decls
-Wpacked
-Wno-padded
-Wmissing-declarations
-Wmissing-prototypes
-Wstrict-prototypes
-Wwrite-strings
-Wcast-qual
-Wundef
-Wfloat-equal
-Warray-bounds
-Wstrict-overflow=4
-Wuninitialized
-Wswitch-enum
-Wswitch-default
-Wmissing-include-dirs
-Wformat-security
-Wnonnull
-Wvla
# Has to be disabled because UTHash uses it
-Wno-implicit-fallthrough
)
if(NOT DEFINED OPTIMIZE)
message("[YASER] Using -O0 -g")
add_compile_options(-O0 -g)
else()
message("[YASER] Using -O3")
add_compile_options(-O3)
endif()
if (CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "DEBUG" OR CMAKE_BUILD_TYPE MATCHES "debug")
message("[YASER] Using -g")
add_compile_options(-g)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options(
-Weverything
-Wno-unknown-warning-option
-Wno-format-nonliteral
-ferror-limit=0)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
add_compile_options(
### WARNINGS
# Standard GCC warnings: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
-Werror
-Wlogical-op
-Wjump-misses-init
-Wunsafe-loop-optimizations
-Wtrampolines
-Wsuggest-attribute=pure
-Wsuggest-attribute=const
-Wsuggest-attribute=noreturn
-Wsuggest-attribute=format
-Wformat=1
-fmax-errors=0
)
endif()
include_directories(external/uthash/src)
include_directories(include)
file(GLOB_RECURSE SRC_FILES "src/*.c")
add_executable(${PRODUCT_NAME} ${SRC_FILES})
if (NOT DEFINED DONT_LINK_TCMALLOC)
target_link_libraries(${PRODUCT_NAME} PUBLIC -ltcmalloc)
endif()
endif()