-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
48 lines (39 loc) · 1.6 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
cmake_minimum_required(VERSION 3.1)
project(BattleEngine C)
option(FAST_MATH "Enable fast math (-ffast-math)" ON)
option(ARCH_NATIVE "Enable optimizations for native arch (-march=native)" OFF)
option(ASAN "Enable Address Sanitizer" OFF)
option(MEMSAN "Enable Memory Sanitizer" OFF)
option(UBSAN "Enable Undefined Behavior Sanitizer" OFF)
option(ANALYZER "Enable static analyzer" OFF)
add_executable(BattleEngine BattleEngine.c)
set_property(TARGET BattleEngine PROPERTY C_STANDARD 99)
if(CMAKE_C_COMPILER_ID MATCHES Clang OR CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(BattleEngine m)
target_compile_options(BattleEngine PRIVATE -Wall -Wextra -Wpedantic -Wconversion)
if(FAST_MATH)
target_compile_options(BattleEngine PRIVATE -ffast-math)
endif()
if(ARCH_NATIVE)
target_compile_options(BattleEngine PRIVATE -march=native)
endif()
if(ASAN)
target_compile_options(BattleEngine PRIVATE -fsanitize=address)
set_property(TARGET BattleEngine APPEND_STRING PROPERTY LINK_FLAGS " -fsanitize=address")
endif()
if(MEMSAN)
target_compile_options(BattleEngine PRIVATE -fsanitize=memory)
set_property(TARGET BattleEngine APPEND_STRING PROPERTY LINK_FLAGS " -fsanitize=memory")
endif()
if(UBSAN)
target_compile_options(BattleEngine PRIVATE -fsanitize=undefined)
set_property(TARGET BattleEngine APPEND_STRING PROPERTY LINK_FLAGS " -fsanitize=undefined")
endif()
if(ANALYZER)
if(CMAKE_C_COMPILER_ID MATCHES Clang)
target_compile_options(BattleEngine PRIVATE --analyze)
else()
target_compile_options(BattleEngine PRIVATE -fanalyzer)
endif()
endif()
endif()