-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
77 lines (66 loc) · 2.35 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
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
project(QryptDemo_project)
set(QRYPTDEMO_TARGET "qrypt")
option(ENABLE_TESTS "Add a validation suite to the qrypt executable" OFF)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# Qrypt Security is built on Windows using the multi-threaded dll runtime library
# Our executable must use the same runtime library.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# Enable -fPIC
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
add_executable(${QRYPTDEMO_TARGET}
src/cli.cpp
src/common.cpp
src/keygen.cpp
src/encrypt.cpp
src/eaas.cpp
)
# Pull in Qrypt Security header files
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_compile_definitions(${QRYPTDEMO_TARGET} PUBLIC MACOS_FRAMEWORK)
target_include_directories(${QRYPTDEMO_TARGET} PUBLIC
"$ENV{HOME}/Library/Frameworks/QryptSecurity.framework/Headers"
)
else()
target_include_directories(${QRYPTDEMO_TARGET} PUBLIC
"QryptSecurity/include"
)
endif()
# Build tests if enabled
if(ENABLE_TESTS)
find_package(GTest REQUIRED)
find_package(Threads REQUIRED)
add_subdirectory(test)
target_compile_definitions(${QRYPTDEMO_TARGET} PUBLIC ENABLE_TESTS)
endif()
# Link against QryptSecurity dynamic library
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(${QRYPTDEMO_TARGET}
${SDKTest_OBJS}
"${CMAKE_CURRENT_LIST_DIR}/QryptSecurity/lib/QryptSecurity.lib"
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_link_libraries(${QRYPTDEMO_TARGET}
${SDKTest_OBJS}
"$ENV{HOME}/Library/Frameworks/QryptSecurity.framework/QryptSecurity"
)
else()
target_link_libraries(${QRYPTDEMO_TARGET}
${SDKTest_OBJS}
"${CMAKE_CURRENT_LIST_DIR}/QryptSecurity/lib/libQryptSecurity.so"
"crypto"
)
endif()
# If on Windows, copy QryptSecurity.dll to the directory where the executable is built
# so that the executable can find it.
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_custom_command(TARGET ${QRYPTDEMO_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_LIST_DIR}/QryptSecurity/bin/QryptSecurity.dll
$<TARGET_FILE_DIR:${QRYPTDEMO_TARGET}>)
endif()