-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
75 lines (62 loc) · 1.98 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
INCLUDE(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/GNUInstallDirs.cmake)
IF(NOT DEFINED LINK)
SET(LINK "STATIC")
ENDIF()
IF(NOT LINK MATCHES "STATIC|DYNAMIC")
MESSAGE(FATAL_ERROR "LINK should be one of STATIC, DYNAMIC")
ENDIF()
IF(NOT DEFINED ARCH)
SET(ARCH "NATIVE")
ENDIF()
IF(NOT ARCH MATCHES "i386|x86_64|amd64|NATIVE")
MESSAGE(FATAL_ERROR "ARCH should be one of i386, amd64, NATIVE")
ENDIF()
IF(NOT DEFINED WITH_CLANG_TIDY)
SET(WITH_CLANG_TIDY "NO")
ENDIF()
IF(NOT WITH_CLANG_TIDY MATCHES "YES|NO")
MESSAGE(FATAL_ERROR "WITH_CLANG_TIDY should be one of YES, NO")
ENDIF()
INCLUDE(external/libseccomp.cmake)
INCLUDE(external/libcap.cmake)
INCLUDE(external/libtclap.cmake)
SET(CMAKE_C_FLAGS "-std=gnu99 -Wall")
SET(CMAKE_C_FLAGS_DEBUG "-g -pedantic")
SET(CMAKE_C_FLAGS_RELEASE "-O2")
SET(CMAKE_CXX_FLAGS "-std=gnu++14 -Wall")
SET(CMAKE_CXX_FLAGS_DEBUG "-g -pedantic")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3")
IF(LINK STREQUAL "STATIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
ENDIF()
IF(ARCH STREQUAL "i386")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
ELSEIF(ARCH MATCHES "amd64|x86_64")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
ENDIF()
EXECUTE_PROCESS(COMMAND uname -r
OUTPUT_VARIABLE BUILD_KERNEL_RELEASE)
ADD_DEFINITIONS('-DBUILD_KERNEL_RELEASE="${BUILD_KERNEL_RELEASE}"')
ENABLE_TESTING()
IF(WITH_CLANG_TIDY STREQUAL "YES")
CMAKE_MINIMUM_REQUIRED(VERSION 3.6.3)
SET(CMAKE_CXX_CLANG_TIDY clang-tidy)
ENDIF()
IF(NOT DEFINED WITH_DOCS)
SET(WITH_DOCS "YES")
ENDIF()
IF(NOT WITH_DOCS MATCHES "YES|NO")
MESSAGE(FATAL_ERROR "WITH_DOCS should be one of YES, NO")
ENDIF()
IF(WITH_DOCS STREQUAL "YES")
INCLUDE(external/scdoc.cmake)
ADD_SUBDIRECTORY(doc)
ENDIF()
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(boxes)
ADD_SUBDIRECTORY(test)