-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
244 lines (194 loc) · 7.36 KB
/
CMakeLists.txt
File metadata and controls
244 lines (194 loc) · 7.36 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.
project(singlefilehost)
set(DOTNET_PROJECT_NAME "singlefilehost")
# Add RPATH to the apphost binary that allows using local copies of shared libraries
# dotnet core depends on for special scenarios when system wide installation of such
# dependencies is not possible for some reason.
# This cannot be enabled for MacOS (Darwin) since its RPATH works in a different way,
# doesn't apply to libraries loaded via dlopen and most importantly, it is not transitive.
if (NOT CLR_CMAKE_TARGET_OSX)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps")
endif()
set(SKIP_VERSIONING 1)
include_directories(..)
include_directories(../../json)
include_directories(${CLR_SRC_LIBS_NATIVE_DIR}/AnyOS/zlib)
if(NOT CLR_CMAKE_TARGET_WIN32)
include_directories(${CLR_SRC_LIBS_NATIVE_DIR}/Unix/Common)
endif()
set(SOURCES
../bundle_marker.cpp
./hostfxr_resolver.cpp
./hostpolicy_resolver.cpp
../../hostpolicy/static/coreclr_resolver.cpp
)
set(HEADERS
../bundle_marker.h
../../hostfxr_resolver.h
)
add_definitions(-D_NO_ASYNCRTIMP)
add_definitions(-D_NO_PPLXIMP)
remove_definitions(-DEXPORT_SHARED_API)
add_definitions(-DHOSTPOLICY_EMBEDDED)
add_definitions(-DNATIVE_LIBS_EMBEDDED)
include(../../fxr/files.cmake)
include(../../hostpolicy/files.cmake)
include(../../hostcommon/files.cmake)
if(MSVC)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4996>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4267>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4018>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4200>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4244>)
# Host components don't try to handle asynchronous exceptions
add_compile_options(/EHsc)
elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
# Prevents libc from calling pthread_cond_destroy on static objects in
# dlopen()'ed library which we dlclose() in pal::unload_library.
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>)
endif()
if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
../apphost.windows.cpp)
list(APPEND HEADERS
../apphost.windows.h)
endif()
if(CLR_CMAKE_TARGET_WIN32)
add_linker_flag("/DEF:${CMAKE_CURRENT_SOURCE_DIR}/singlefilehost.def")
else()
if(CLR_CMAKE_TARGET_OSX)
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/singlefilehost_OSXexports.src)
else()
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/singlefilehost_unixexports.src)
endif()
set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/singlefilehost.exports)
generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE})
set_exports_linker_option(${EXPORTS_FILE})
endif()
if (CLR_SINGLE_FILE_HOST_ONLY)
set(ADDITIONAL_INSTALL_ARGUMENTS COMPONENT runtime)
endif()
include(../../exe.cmake)
include(configure.cmake)
if(CLR_CMAKE_HOST_UNIX)
add_custom_target(singlefilehost_exports DEPENDS ${EXPORTS_FILE})
add_dependencies(singlefilehost singlefilehost_exports)
set_property(TARGET singlefilehost APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION})
set_property(TARGET singlefilehost APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})
endif()
add_definitions(-DFEATURE_APPHOST=1)
add_definitions(-DFEATURE_STATIC_HOST=1)
if(CLR_CMAKE_TARGET_WIN32)
# Disable manifest generation into the file .exe on Windows
add_linker_flag("/MANIFEST:NO")
# Incremental linking results in the linker inserting extra padding and routing function calls via thunks that can break the
# invariants (e.g. size of region between Jit_PatchedCodeLast-Jit_PatchCodeStart needs to fit in a page).
add_linker_flag("/INCREMENTAL:NO")
endif()
if(CLR_CMAKE_TARGET_WIN32)
set(NATIVE_LIBS
coreclr_static
System.Globalization.Native-Static
System.IO.Compression.Native-Static
kernel32.lib
advapi32.lib
ole32.lib
oleaut32.lib
uuid.lib
user32.lib
version.lib
shlwapi.lib
shell32.lib
bcrypt.lib
RuntimeObject.lib
)
set(RUNTIMEINFO_LIB runtimeinfo)
else()
set(NATIVE_LIBS
coreclr_static
System.Globalization.Native-Static
System.IO.Compression.Native-Static
System.Net.Security.Native-Static
System.Native-Static
System.Security.Cryptography.Native.OpenSsl-Static
palrt
coreclrpal
eventprovider
nativeresourcestring
)
# additional requirements for System.IO.Compression.Native
include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake)
append_extra_compression_libs(NATIVE_LIBS)
# Additional requirements for System.Net.Security.Native
include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake)
append_extra_security_libs(NATIVE_LIBS)
# Additional requirements for System.Native
include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Native/extra_libs.cmake)
append_extra_system_libs(NATIVE_LIBS)
# Additional requirements for System.Security.Cryptography.Native.OpenSsl
include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake)
append_extra_cryptography_libs(NATIVE_LIBS)
set(RUNTIMEINFO_LIB runtimeinfo)
endif()
if(CLR_CMAKE_TARGET_OSX)
LIST(APPEND NATIVE_LIBS
System.Security.Cryptography.Native.Apple-Static
)
# Additional requirements for System.Security.Cryptography.Native.Apple
include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/extra_libs.cmake)
append_extra_cryptography_apple_libs(NATIVE_LIBS)
endif()
#
# Additional requirements for coreclr
#
if(CLR_CMAKE_TARGET_OSX)
find_library(COREFOUNDATION CoreFoundation)
find_library(CORESERVICES CoreServices)
find_library(SECURITY Security)
find_library(SYSTEM System)
LIST(APPEND NATIVE_LIBS
${COREFOUNDATION}
${CORESERVICES}
${SECURITY}
${SYSTEM}
)
elseif(CLR_CMAKE_TARGET_NETBSD)
find_library(KVM kvm)
LIST(APPEND NATIVE_LIBS
${KVM}
)
elseif (CLR_CMAKE_TARGET_SUNOS)
LIST(APPEND NATIVE_LIBS
socket
)
endif(CLR_CMAKE_TARGET_OSX)
# On *BSD, we always use the libunwind that's part of the OS
if(CLR_CMAKE_TARGET_FREEBSD)
set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1)
endif()
if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
find_unwind_libs(UNWIND_LIBS)
LIST(APPEND NATIVE_LIBS
${UNWIND_LIBS}
)
endif()
if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS)
# These options are used to force every object to be included even if it's unused.
set(START_WHOLE_ARCHIVE -Wl,--whole-archive)
set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive)
endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS)
if(CLR_CMAKE_TARGET_OSX)
# These options are used to force every object to be included even if it's unused.
set(START_WHOLE_ARCHIVE -force_load)
set(END_WHOLE_ARCHIVE )
endif(CLR_CMAKE_TARGET_OSX)
set_property(TARGET singlefilehost PROPERTY ENABLE_EXPORTS 1)
target_link_libraries(
singlefilehost
${NATIVE_LIBS}
${START_WHOLE_ARCHIVE}
${RUNTIMEINFO_LIB}
${END_WHOLE_ARCHIVE}
)