-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
68 lines (55 loc) · 2.15 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
cmake_minimum_required(VERSION 2.8)
project(TpmCrypt CXX)
include(CheckCXXCompilerFlag)
include(FindPackageHandleStandardArgs)
set(PROJECT_BINARY_DIR bin)
set(TpmCrypt_MAJOR_VERSION 0)
set(TpmCrypt_MINOR_VERSION 0)
set(TpmCrypt_PATCH_VERSION 1)
set(TpmCrypt_VERSION
${TpmCrypt_MAJOR_VERSION}.${TpmCrypt_MINOR_VERSION}.${TpmCrypt_PATCH_VERSION})
option(TpmCrypt_BUILD "Build TpmCrypt Tool (tpmcrypt-console)" ON)
# C++ & Compiler Flags
add_definitions("-O2 -Wall -pedantic -Wextra")
add_definitions("-fprofile-arcs -ftest-coverage")
# Security Flags
add_definitions("-Wformat -Wformat-security -Werror=format-security
-fstack-protector-all --param ssp-buffer-size=4 -fpic -pie")
# Security Linking Flags
set(CMAKE_SHARED_LINKER_FLAGS "-z,relro,-z,now")
# Dependencies
CHECK_CXX_COMPILER_FLAG("-std=c++0x" CXXFLAG_CPP0X)
CHECK_CXX_COMPILER_FLAG("-std=c++11" CXXFLAG_CPP11)
# Release mode is default
if(NOT DEFINED "CMAKE_BUILD_TYPE" OR "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
add_definitions("-Werror")
message("Build release")
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
include(CTest)
message("Build debug")
endif()
find_path(blkid_INCLUDE_DIRS blkid/blkid.h)
find_library(blkid_LIBRARIES blkid)
find_package_handle_standard_args(BLKID REQUIRED_VARS
blkid_LIBRARIES blkid_INCLUDE_DIRS)
find_path(tspi_INCLUDE_DIRS trousers/trousers.h)
find_library(tspi_LIBRARIES tspi)
find_package_handle_standard_args(TROUSERS REQUIRED_VARS
tspi_LIBRARIES tspi_INCLUDE_DIRS)
find_path(cryptopp_INCLUDE_DIRS crypto++/default.h)
find_library(cryptopp_LIBRARIES crypto++)
find_package_handle_standard_args(CRYPTOPP REQUIRED_VARS
cryptopp_LIBRARIES cryptopp_INCLUDE_DIRS)
# C++11 flags
if(CXXFLAG_CPP11)
add_definitions("-std=c++11")
elseif(CXXFLAG_CPP0X)
add_definitions("-std=c++0x")
else()
message(FATAL_ERROR "Your compiler does not support C++11. Please use clang
3.0 or GCC 4.7.")
endif()
file(GLOB TpmCrypt_SOURCES crypto/*.cpp externals/*.cpp management/*.cpp protocol/*.cpp tools/*.cpp utils/*.cpp tpm/*.cpp)
file(GLOB TpmCrypt_HEADERS crypto/*.h externals/*.h management/*.h protocol/*.h tools/*.h utils/*.h tpm/*.h)
add_subdirectory("cli")
add_subdirectory("tests")