forked from dogtagpki/jss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
147 lines (121 loc) · 4.2 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# This is the CMakeLists.txt for the JSS Project.
project(jss)
# Required cmake version; set a 3.14.2 since we need LINK_OPTIONS in
# try_compile.
cmake_minimum_required(VERSION 3.14.0)
# Source our custom CMake modules; this includes NSS and NSPR modules from
# PKI and the JSSConfig and JSSCommon modules.
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# Define optional variables and conditionals.
if (DEFINED ENV{CHECK_DEPRECATION})
set(CHECK_DEPRECATION_ENV TRUE)
endif()
option(CHECK_DEPRECATION "When enabled, utilize the deprecation checking functionality of the java compiler." ${CHECK_DEPRECATION_ENV})
if (CHECK_DEPRECATION)
list(APPEND JSS_JAVAC_FLAGS "-Xlint:deprecation")
endif()
if (DEFINED ENV{FIPS_ENABLED})
set(FIPS_ENABLED_ENV TRUE)
endif()
option(FIPS_ENABLED "When enabled, disable certain tests which don't work in FIPS mode. This should only be specified when the host system is in FIPS mode." ${FIPS_ENABLED_ENV})
if (DEFINED ENV{SANDBOX})
set(SANDBOX_ENV TRUE)
endif()
option(SANDBOX "When enabled, expect to find nss and nspr from the parent (sandbox) directory instead of using the system-installed versions of the libraries." ${SANDBOX_ENV})
if (DEFINED ENV{TEST_VALGRIND})
set(TEST_VALGRIND_ENV TRUE)
endif()
option(TEST_VALGRIND "When enabled, run the entire test suite under Valgrind. This will be noisy as JSS can't clean up NSS initialization and the JVM itself leaks." ${TEST_VALGRIND_ENV})
# Build a debug build by default when no type is specified on the command line
if(NOT (DEFINED CMAKE_BUILD_TYPE))
set(CMAKE_BUILD_TYPE "Debug")
endif()
if (DEFINED ENV{WITH_INTERNET})
set(TEST_WITH_INTERNET_ENV TRUE)
endif()
option(TEST_WITH_INTERNET "When enabled, runs various tests which require an internet connection. " ${TEST_WITH_INTERNET_ENV})
option(WITH_JAVA "Build Java binaries." TRUE)
option(WITH_NATIVE "Build native binaries." TRUE)
option(WITH_JAVADOC "Build Javadoc package." TRUE)
option(WITH_TESTS "Run unit tests." TRUE)
# Find NSPR and NSS Libraries.
find_package(NSPR REQUIRED)
find_package(NSS REQUIRED)
# Find Java and JNI packages; this sets CMake wariables like
# Java_JAVAC_EXECUTABLE.
find_package(Java REQUIRED)
find_package(JNI REQUIRED)
# Shims for older CMake versions without useful features.
include(Shims)
# Since we found Java, include UseJava to provide the find_jar function.
include(UseJava)
include(Java)
# These includes are required for the macro check_symbol_exists and
# check_struct_has_member in jss_config().
include(CheckSymbolExists)
include(CheckStructHasMember)
# Load JSSConfig module; this defines the jss_config() macro which defines
# JSS-specific configuration values.
include(JSSConfig)
# Load JSSCommon module; this defines the jss_build() macros which defines
# the JSS build procedure.
include(JSSCommon)
# Load JSSTests module; this defines the jss_tests() macro which defines the
# JSS test procedure.
include(JSSTests)
jss_config()
jss_build()
jss_tests()
add_subdirectory(symkey)
add_custom_target(
java ALL
DEPENDS generate_java generate_jar
)
add_custom_target(
native ALL
DEPENDS generate_c generate_so symkey_library
)
if(WITH_JAVA)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/jss.jar
DESTINATION
${JNI_DIR}
)
install(
CODE "
MESSAGE(
\"-- Installing: \$ENV{DESTDIR}${LIB_DIR}/jss/jss.jar\"
)
execute_process(
COMMAND ln -sf ../../../${JNI_DIR}/jss.jar \$ENV{DESTDIR}${LIB_DIR}/jss/jss.jar
)
"
)
endif(WITH_JAVA)
if(WITH_NATIVE)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/libjss.so
DESTINATION
${LIB_DIR}/jss
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
endif(WITH_NATIVE)
if(WITH_JAVADOC)
install(
DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/docs/
DESTINATION
${CMAKE_INSTALL_PREFIX}/share/javadoc/jss
)
install(
FILES
jss.html MPL-1.1.txt gpl.txt lgpl.txt symkey/LICENSE
DESTINATION
${CMAKE_INSTALL_PREFIX}/share/javadoc/jss
)
endif(WITH_JAVADOC)