-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
76 lines (63 loc) · 3.09 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
# This program is free software licenced under MIT Licence. You can
# find a copy of this licence in LICENCE.txt in the top directory of
# source code.
#
#=============================================================================
# Setup project
#=============================================================================
project(AI_AB CXX)
cmake_minimum_required(VERSION 2.8)
#=============================================================================
# Setup CMake options
#=============================================================================
include(CMakeDependentOption)
option(AI_AB_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
option(AI_AB_ENABLE_WERROR "Fail and stop if a warning is triggered." ON)
option(AI_AB_ENABLE_CXX14 "Use the -std=c++14 switch if the compiler supports it." ON)
option(AI_AB_OPTIMIZE_COMPILATION "Use the -O3 and -funroll-loops compilation flags." ON)
set(CMAKE_BUILD_TYPE Debug)
#=============================================================================
# Setup compiler flags
#=============================================================================
include(CheckCXXCompilerFlag)
macro(ai_ab_append_flag lst testname flag)
check_cxx_compiler_flag(${flag} ${testname})
if (${testname})
list(APPEND ${lst} ${flag})
endif()
endmacro()
ai_ab_append_flag(AI_AB_CXX_WARNING_FLAGS AI_AB_HAS_W_FLAG -W)
ai_ab_append_flag(AI_AB_CXX_WARNING_FLAGS AI_AB_HAS_WALL_FLAG -Wall)
ai_ab_append_flag(AI_AB_CXX_WARNING_FLAGS AI_AB_HAS_WEXTRA_FLAG -Wextra)
ai_ab_append_flag(AI_AB_CXX_WARNING_FLAGS AI_AB_HAS_WNO_LONG_LONG_FLAG -Wno-long-long)
ai_ab_append_flag(AI_AB_CXX_WARNING_FLAGS AI_AB_HAS_WNO_UNUSED_LOCAL_TYPEDEFS_FLAG -Wno-unused-local-typedefs)
ai_ab_append_flag(AI_AB_CXX_WARNING_FLAGS AI_AB_HAS_WNO_UNUSED_PARAMETER_FLAG -Wno-unused-parameter)
ai_ab_append_flag(AI_AB_CXX_WARNING_FLAGS AI_AB_HAS_WWRITE_STRINGS_FLAG -Wwrite-strings)
if (AI_AB_ENABLE_WERROR)
ai_ab_append_flag(AI_AB_CXX_WARNING_FLAGS AI_AB_HAS_WERROR_FLAG -Werror)
ai_ab_append_flag(AI_AB_CXX_WARNING_FLAGS AI_AB_HAS_WX_FLAG -WX)
endif()
if (AI_AB_ENABLE_PEDANTIC)
ai_ab_append_flag(AI_AB_CXX_WARNING_FLAGS AI_AB_HAS_PEDANTIC_FLAG -pedantic)
endif()
if (AI_AB_ENABLE_CXX14)
ai_ab_append_flag(AI_AB_CXX_FEATURE_FLAGS AI_AB_HAS_STDCXX14_FLAG -std=c++14)
endif()
if (AI_AB_OPTIMIZE_COMPILATION)
ai_ab_append_flag(AI_AB_CXX_FEATURE_FLAGS AI_AB_HAS_O_THREE_FLAG -O3)
ai_ab_append_flag(AI_AB_CXX_FEATURE_FLAGS AI_AB_HAS_F_UNROLL_LOOPS_FLAG -funroll-loops)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
ai_ab_append_flag(AI_AB_CXX_FEATURE_FLAGS AI_AB_HAS_STDLIB_LIBCXX_FLAG -stdlib=libc++)
endif()
add_compile_options(
${AI_AB_CXX_WARNING_FLAGS}
${AI_AB_CXX_FEATURE_FLAGS}
)
#=============================================================================
# Setup subdirectories
#=============================================================================
enable_testing()
include_directories(include src)
add_subdirectory(src)
add_subdirectory(test)