forked from openenclave/openenclave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
103 lines (86 loc) · 3.06 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
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
# Top-level CMake file for the Open Enclave SDK
#
# Please read The Ultimate Guide to CMake:
# https://rix0r.nl/blog/2015/08/13/cmake-guide/
cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR)
# Read version from "VERSION" file.
file(STRINGS "VERSION" OE_VERSION_WITH_V)
string(REGEX REPLACE "^v" "" OE_VERSION ${OE_VERSION_WITH_V})
# Select the assembler
# TODO: See #755: This should probably be removed
if (UNIX)
set(OE_ASM ASM)
elseif (WIN32)
set(OE_ASM ASM_MASM)
endif ()
# Set compiler search order to prefer Clang
# This has to be done before `project`
# http://cmake.3232098.n2.nabble.com/Prefer-clang-over-gcc-td7597742.html
set(CMAKE_C_COMPILER_NAMES clang-7 cc)
set(CMAKE_CXX_COMPILER_NAMES clang++-7 c++)
project("Open Enclave SDK" VERSION ${OE_VERSION} LANGUAGES C CXX ${OE_ASM})
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# Collect Git info
if (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git")
execute_process(
COMMAND git rev-parse HEAD
OUTPUT_VARIABLE GIT_COMMIT
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND git symbolic-ref HEAD
OUTPUT_VARIABLE GIT_BRANCH
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()
# Get Jenkins build number
set(BUILD_NUMBER $ENV{BUILD_NUMBER})
if (NOT BUILD_NUMBER)
set(BUILD_NUMBER "0")
endif ()
# See `cmake/compiler_settings.cmake` for all compiler settings
include(compiler_settings)
# See `cmake/package_settings.cmake` for all package settings
include(package_settings)
# User configurable options
option(USE_LIBSGX "Build oehost using SGX library requiring FLC" OFF)
if (USE_LIBSGX AND WIN32)
message(FATAL_ERROR "USE_LIBSGX is not supported on Windows. Disable this when calling cmake with -DUSE_LIBSGX=OFF")
endif ()
# TODO: See #756: Fix this because it is incompatible with
# multi-configuration generators
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT WIN32)
# In non-win32 debug build, debug_malloc is on by default
option(USE_DEBUG_MALLOC "Build oeenclave with memory leak detection capability." ON)
else ()
# In win32 or non-debug builds, debug_malloc is off by default
option(USE_DEBUG_MALLOC "Build oeenclave with memory leak detection capability." OFF)
endif ()
if (USE_DEBUG_MALLOC AND WIN32)
message(FATAL_ERROR "USE_DEBUG_MALLOC is not supported on Windows. Disable this when calling cmake with -DUSE_DEBUG_MALLOC=OFF")
endif ()
option(ADD_WINDOWS_ENCLAVE_TESTS "Build Windows enclave tests" OFF)
# Configure testing
enable_testing()
include(add_enclave_test)
# Recurse through subdirectories
add_subdirectory(host)
add_subdirectory(include)
add_subdirectory(tests)
add_subdirectory(tools)
if (UNIX)
add_subdirectory(3rdparty)
add_subdirectory(debugger)
add_subdirectory(docs/refman)
add_subdirectory(enclave)
add_subdirectory(enclave/core)
add_subdirectory(libc)
add_subdirectory(libcxx)
add_subdirectory(pkgconfig)
add_subdirectory(samples)
endif ()