-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCMakeLists.txt
92 lines (79 loc) · 3.11 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(cryptopp)
###################################
# Global platform-specific settings
###################################
IF(WIN32)
ADD_DEFINITIONS(-DWIN32 -D_WINDOWS -D_CRT_SECURE_NO_WARNINGS -MP -D_SCL_SECURE_NO_WARNINGS -EHsc)
SET(CMAKE_CXX_FLAGS "-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS")
ELSE()
SET(ADDED_DEFINITIONS -Wall -Wno-unused-function -Wno-unused-variable -fvisibility=hidden -fPIC -Wnon-virtual-dtor -Wreorder -Wstrict-null-sentinel -Wsign-promo)
IF(APPLE)
ADD_DEFINITIONS("-DCRYPTOPP_DISABLE_ASM")
ENDIF()
ENDIF()
ADD_DEFINITIONS(${ADDED_DEFINITIONS})
SET(CRYPTOPP_LDFLAGS "")
#########################
# User Settings
#########################
IF(CRYPTOPP_ADDED_DEFINITIONS)
ADD_DEFINITIONS(${CRYPTOPP_ADDED_DEFINITIONS})
ENDIF()
IF(CRYPTOPP_ADDED_LDFLAGS)
SET(CRYPTOPP_LDFLAGS ${CRYPTOPP_LDFLAGS} ${CRYPTOPP_ADDED_LDFLAGS})
ENDIF()
IF(NOT DEFINED CRYPTOPP_LIBRARY_TYPE)
SET(CRYPTOPP_LIBRARY_TYPE "BOTH" CACHE STRING "Type of library to build, STATIC, SHARED or BOTH.")
ELSE()
SET(CRYPTOPP_LIBRARY_TYPE ${CRYPTOPP_LIBRARY_TYPE} CACHE STRING "Type of library to build, STATIC or SHARED.")
ENDIF()
IF(NOT DEFINED CRYPTOPP_RUNTIME_TYPE)
SET(CRYPTOPP_RUNTIME_TYPE "STATIC" CACHE STRING "Type of runtime to use, STATIC or SHARED.")
ELSE()
SET(CRYPTOPP_RUNTIME_TYPE ${CRYPTOPP_RUNTIME_TYPE} CACHE STRING "Type of runtime to use, STATIC or SHARED.")
ENDIF()
IF(NOT DEFINED CRYPTOPP_BUILD_TESTS)
SET(CRYPTOPP_BUILD_TESTS TRUE CACHE BOOL "If enabled, builds tests.")
ELSE()
SET(CRYPTOPP_BUILD_TESTS ${CRYPTOPP_BUILD_TESTS} CACHE BOOL "If enabled, builds tests.")
ENDIF()
#########################
# Project-wide Settings
#########################
SET(EXEC_PERMS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
STRING(TOUPPER ${CRYPTOPP_LIBRARY_TYPE} CRYPTOPP_LIBRARY_TYPE_UPPER)
STRING(COMPARE EQUAL "${CRYPTOPP_LIBRARY_TYPE_UPPER}" "STATIC" CRYPTOPP_STATIC)
IF(NOT CRYPTOPP_STATIC)
STRING(COMPARE EQUAL "${CRYPTOPP_LIBRARY_TYPE_UPPER}" "BOTH" CRYPTOPP_STATIC)
ENDIF()
STRING(COMPARE EQUAL "${CRYPTOPP_LIBRARY_TYPE_UPPER}" "SHARED" CRYPTOPP_SHARED)
IF(NOT CRYPTOPP_SHARED)
STRING(COMPARE EQUAL "${CRYPTOPP_LIBRARY_TYPE_UPPER}" "BOTH" CRYPTOPP_SHARED)
ENDIF()
STRING(TOUPPER ${CRYPTOPP_RUNTIME_TYPE} CRYPTOPP_RUNTIME_TYPE_UPPER)
STRING(COMPARE EQUAL ${CRYPTOPP_RUNTIME_TYPE_UPPER} "STATIC" CRYPTOPP_STATIC_RUNTIME)
SET(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
IF(CRYPTOPP_STATIC_RUNTIME)
IF(WIN32)
FOREACH(CompilerFlag ${CompilerFlags})
STRING(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
STRING(REPLACE "/MDd" "/MTd" ${CompilerFlag} "${${CompilerFlag}}")
ENDFOREACH()
ENDIF()
ELSE()
IF(WIN32)
FOREACH(CompilerFlag ${CompilerFlags})
STRING(REPLACE "/MT" "/MD" ${CompilerFlag} "${${CompilerFlag}}")
STRING(REPLACE "/MTd" "/MDd" ${CompilerFlag} "${${CompilerFlag}}")
ENDFOREACH()
ENDIF()
ENDIF()
ADD_SUBDIRECTORY(src)