-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
CMakeLists.txt
141 lines (120 loc) · 4.61 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
project(System.Security.Cryptography.Native.Apple C)
include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake)
set(NATIVE_LIBS_EXTRA)
append_extra_cryptography_apple_libs(NATIVE_LIBS_EXTRA)
set(NATIVECRYPTO_SOURCES
pal_digest.c
pal_ecc.c
pal_hmac.c
pal_keyagree.c
pal_keyderivation.c
pal_random.c
pal_rsa.c
pal_sec.c
pal_seckey.c
pal_signverify.c
pal_ssl.c
pal_symmetric.c
pal_x509.c
pal_x509chain.c
pal_swiftbindings.o
)
if (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
set(NATIVECRYPTO_SOURCES
${NATIVECRYPTO_SOURCES}
pal_keychain_ios.c
pal_x509_ios.c
)
else()
set(NATIVECRYPTO_SOURCES
${NATIVECRYPTO_SOURCES}
pal_keychain_macos.c
pal_seckey_macos.c
pal_trust_macos.c
pal_x509_macos.c
)
endif()
# As of CMake 3.20.2 support for Swift only works with the Ninja and XCode
# generators so we cannot rely on it. Even with the Ninja generator it doesn't
# work in combination with other languages within the same library.
if (NOT SWIFT_COMPILER_TARGET)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(SWIFT_OPTIMIZATION_FLAG "-Onone")
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
set(SWIFT_OPTIMIZATION_FLAG "-O")
endif()
if (CLR_CMAKE_TARGET_MACCATALYST)
# this is set in configurecompiler.cmake
set(SWIFT_COMPILER_TARGET ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET})
else()
set(SWIFT_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
set(SWIFT_PLATFORM_SUFFIX "")
if (CLR_CMAKE_TARGET_OSX)
set(SWIFT_PLATFORM "macosx")
elseif (CLR_CMAKE_TARGET_IOS)
set(SWIFT_PLATFORM "ios")
if (CMAKE_OSX_SYSROOT MATCHES iPhoneSimulator)
set(SWIFT_PLATFORM_SUFFIX "-simulator")
endif()
elseif (CLR_CMAKE_TARGET_TVOS)
set(SWIFT_PLATFORM "tvos")
if (CMAKE_OSX_SYSROOT MATCHES AppleTVSimulator)
set(SWIFT_PLATFORM_SUFFIX "-simulator")
endif()
else()
message(FATAL_ERROR "Unknown platform")
endif()
set(SWIFT_COMPILER_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-${SWIFT_PLATFORM}${SWIFT_DEPLOYMENT_TARGET}${SWIFT_PLATFORM_SUFFIX}")
endif()
endif()
add_custom_command(
OUTPUT pal_swiftbindings.o
COMMAND xcrun swiftc -emit-object -static -parse-as-library -enable-library-evolution -g ${SWIFT_OPTIMIZATION_FLAG} -runtime-compatibility-version none -sdk ${CMAKE_OSX_SYSROOT} -target ${SWIFT_COMPILER_TARGET} ${CMAKE_CURRENT_SOURCE_DIR}/pal_swiftbindings.swift -o pal_swiftbindings.o
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/pal_swiftbindings.swift
COMMENT "Compiling Swift file pal_swiftbindings.swift"
)
set_source_files_properties(pal_swiftbindings.o PROPERTIES EXTERNAL_OBJECT true GENERATED true)
if (CLR_CMAKE_TARGET_MACCATALYST)
add_definitions(-DTARGET_MACCATALYST)
endif()
if (CLR_CMAKE_TARGET_IOS)
add_definitions(-DTARGET_IOS)
endif()
if (CLR_CMAKE_TARGET_TVOS)
add_definitions(-DTARGET_TVOS)
endif()
if (GEN_SHARED_LIB)
add_library(System.Security.Cryptography.Native.Apple
SHARED
${NATIVECRYPTO_SOURCES}
${VERSION_FILE_PATH}
)
endif()
if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
set(NATIVECRYPTO_SOURCES ${NATIVECRYPTO_SOURCES} entrypoints.c)
endif()
add_library(System.Security.Cryptography.Native.Apple-Static
STATIC
${NATIVECRYPTO_SOURCES}
)
set_target_properties(System.Security.Cryptography.Native.Apple-Static PROPERTIES OUTPUT_NAME System.Security.Cryptography.Native.Apple CLEAN_DIRECT_OUTPUT 1)
if (GEN_SHARED_LIB)
target_link_libraries(System.Security.Cryptography.Native.Apple
PRIVATE
${NATIVE_LIBS_EXTRA}
)
if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
add_custom_command(TARGET System.Security.Cryptography.Native.Apple POST_BUILD
COMMENT "Verifying System.Security.Cryptography.Native.Apple points against entrypoints.c "
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-entrypoints.sh
$<TARGET_FILE:System.Security.Cryptography.Native.Apple>
${CMAKE_CURRENT_SOURCE_DIR}/entrypoints.c
${CMAKE_NM}
VERBATIM
)
endif()
endif()
if (GEN_SHARED_LIB)
install_with_stripped_symbols (System.Security.Cryptography.Native.Apple PROGRAMS .)
endif()
install (TARGETS System.Security.Cryptography.Native.Apple-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs)