-
Notifications
You must be signed in to change notification settings - Fork 75
/
CMakeLists.txt
91 lines (79 loc) · 2.99 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
# Software-based Trusted Platform Module (TPM) Emulator
# Copyright (C) 2004-2010 Mario Strasser <[email protected]>
#
# $Id: CMakeLists.txt 475 2011-12-20 18:21:19Z mast $
project(TPM_Emulator C)
cmake_minimum_required(VERSION 2.4)
include(GNUInstallDirs)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif()
# enforce out of source build
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" IS_INSOURCE)
if(IS_INSOURCE)
message(FATAL_ERROR "${PROJECT_NAME} requires an out of source build.")
endif()
# set project and build version
set(${PROJECT_NAME}_VERSION_MAJOR 0)
set(${PROJECT_NAME}_VERSION_MINOR 7)
string(REGEX REPLACE ".*Revision: ([0-9]+).*" "\\1" ${PROJECT_NAME}_VERSION_BUILD "$Revision: 475 $")
# create project configuration
if(WIN32)
STRING(REGEX REPLACE "\\\\" "/" PROGRAMFILES "$ENV{PROGRAMFILES}/${PROJECT_NAME}")
set(TPM_LOG_FILE "${PROGRAMFILES}/tpmd.log")
set(TPM_STORAGE_NAME "${PROGRAMFILES}/tpm_emulator-1_2_${${PROJECT_NAME}_VERSION_MAJOR}_${${PROJECT_NAME}_VERSION_MINOR}")
set(TPM_DEVICE_NAME "//./pipe/tpmd:0")
elseif(APPLE)
set(TPM_LOG_FILE "/private/var/log/tpmd.log")
set(TPM_SOCKET_NAME "/private/var/run/tpm/tpmd_socket:0")
set(TPM_STORAGE_NAME "/private/var/lib/tpm/tpm_emulator-1_2_${${PROJECT_NAME}_VERSION_MAJOR}_${${PROJECT_NAME}_VERSION_MINOR}")
set(TPM_DEVICE_NAME "/dev/tpm")
else()
set(TPM_LOG_FILE "/var/log/tpmd.log")
set(TPM_SOCKET_NAME "/var/run/tpm/tpmd_socket:0")
set(TPM_STORAGE_NAME "/var/lib/tpm/tpm_emulator-1_2_${${PROJECT_NAME}_VERSION_MAJOR}_${${PROJECT_NAME}_VERSION_MINOR}")
set(TPM_DEVICE_NAME "/dev/tpm")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
add_definitions(-Wall -Wno-unused-parameter -Wpointer-arith -Wcast-align -Wwrite-strings)
option(ENABLE_WERROR "Make warnings into errors")
if(ENABLE_WERROR)
add_definitions(-Werror)
endif()
if("${CMAKE_SYSTEM}" MATCHES "Linux")
add_definitions(-Wextra)
endif()
if(USE_OPENSSL)
add_definitions(-DUSE_OPENSSL)
endif()
include_directories("/opt/local/include")
link_directories("/opt/local/lib")
# configure CPack
set(CPACK_PACKAGE_VERSION_MAJOR ${${PROJECT_NAME}_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${${PROJECT_NAME}_VERSION_MINOR})
set(CPACK_SOURCE_PACKAGE_FILE_NAME "tpm_emulator-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.4")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES ".svn/" "/build/" "/.project" "/.cproject")
set(CPACK_GENERATOR "ZIP")
set(CPACK_SET_DESTDIR ON)
include(CPack)
# include root directories
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_BINARY_DIR})
# add internal libraries
add_subdirectory(tpm)
option(MTM_EMULATOR "MTM emulator")
if(MTM_EMULATOR)
add_subdirectory(mtm)
endif()
add_subdirectory(crypto)
# add TDDL
add_subdirectory(tddl)
# add kernel modules
option(BUILD_DEV "Build linux kernel module" ON)
if(BUILD_DEV)
add_subdirectory(tpmd_dev)
endif()
# add executables
add_subdirectory(tpmd)