-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
71 lines (58 loc) · 2.38 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.6)
project(LYRIC)
set(CMAKE_BUILD_TYPE Debug)
include(CheckFunctionExists)
include(CheckCCompilerFlag)
if(MSVC)
# MSVC needs different flags at all
check_c_compiler_flag("/W3" HAVE_W3)
if(HAVE_W3)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
endif(HAVE_W3)
else(MSVC)
# Check for extra compiler flags we want to use
check_c_compiler_flag("-Wall" HAVE_WALL)
if(HAVE_WALL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
endif(HAVE_WALL)
check_c_compiler_flag("-Wno-pointer-sign" HAVE_WPOINTERSIGN)
if(HAVE_WPOINTERSIGN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-pointer-sign")
endif(HAVE_WPOINTERSIGN)
check_c_compiler_flag("-Werror-implicit-function-declaration" HAVE_WERRORIMPLICITDECLARATION)
if(HAVE_WERRORIMPLICITDECLARATION)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror-implicit-function-declaration")
endif(HAVE_WERRORIMPLICITDECLARATION)
check_c_compiler_flag("-Wdeclaration-after-statement" HAVE_WDECLARATIONAFTERSTATEMENT)
if(HAVE_WDECLARATIONAFTERSTATEMENT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeclaration-after-statement")
endif(HAVE_WDECLARATIONAFTERSTATEMENT)
check_c_compiler_flag("-Wpointer-arith" HAVE_WPOINTERARITH)
if(HAVE_WPOINTERARITH)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith")
endif(HAVE_WPOINTERARITH)
check_c_compiler_flag("-Wshadow" HAVE_WSHADOW)
if(HAVE_WSHADOW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
endif(HAVE_WSHADOW)
# check_c_compiler_flag("-Werror" HAVE_WERROR)
# if(HAVE_WERROR)
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
# endif(HAVE_WERROR)
if(CMAKE_BUILD_TYPE STREQUAL Release)
check_c_compiler_flag("-Wp,-D_FORTIFY_SOURCE=2" HAVE_FORTIFY_SOURCE)
if(HAVE_FORTIFY_SOURCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wp,-D_FORTIFY_SOURCE=2")
endif(HAVE_FORTIFY_SOURCE)
endif(CMAKE_BUILD_TYPE STREQUAL Release)
check_c_compiler_flag("-fsanitize=address" HAVE_ADDRESS_SANITIZER)
if(HAVE_ADDRESS_SANITIZER)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-common")
endif(HAVE_ADDRESS_SANITIZER)
endif(MSVC)
check_function_exists(strcasecmp STRCASECMP)
if(STRCASECMP)
add_definitions(-DHAVE_STRCASECMP)
endif()
add_subdirectory(lib)
add_subdirectory(src)