Skip to content

Commit f0b27bc

Browse files
authored
Merge pull request #80208 from compnerd/reorganise
Runtimes: reorganise flags for swiftCore
2 parents 815c3e8 + d19fd71 commit f0b27bc

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

Runtimes/Core/core/CMakeLists.txt

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ if(NOT LINUX AND NOT ANDROID)
250250
target_sources(swiftCore PRIVATE ObjectIdentifier+DebugDescription.swift)
251251
endif()
252252

253-
set_target_properties(swiftCore PROPERTIES Swift_MODULE_NAME Swift)
254-
255253
if(SwiftCore_ENABLE_COMMANDLINE_SUPPORT)
256254
target_sources(swiftCore PRIVATE CommandLine.swift)
257255
target_link_libraries(swiftCore PRIVATE swiftCommandLineSupport)
@@ -271,11 +269,18 @@ if(SwiftCore_ENABLE_VECTOR_TYPES)
271269
"${CMAKE_CURRENT_BINARY_DIR}/SIMDVectorTypes.swift")
272270
endif()
273271

274-
if(APPLE AND BUILD_SHARED_LIBS)
275-
target_link_options(swiftCore PRIVATE "SHELL:-Xlinker -headerpad_max_install_names")
276-
endif()
272+
set_target_properties(swiftCore PROPERTIES Swift_MODULE_NAME Swift)
273+
274+
target_compile_definitions(swiftCore
275+
PRIVATE
276+
$<$<BOOL:${SwiftCore_ENABLE_REFLECTION}>:-DSWIFT_ENABLE_REFLECTION>
277+
$<$<BOOL:${SwiftCore_ENABLE_COMPACT_ABSOLUTE_FUNCTION_POINTERS}>:-DSWIFT_COMPACT_ABSOLUTE_FUNCTION_POINTER>
278+
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_TARGET_LIBRARY_NAME=swiftCore>
279+
INTERFACE
280+
$<$<BOOL:${SwiftCore_ENABLE_VECTOR_TYPES}>:-DSWIFT_STDLIB_ENABLE_VECTOR_TYPES>)
277281

278282
target_compile_options(swiftCore PRIVATE
283+
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<BOOL:${BUILD_SHARED_LIBS}>>:SHELL:-Xcc -DswiftCore_EXPORTS>"
279284
# STAGING: Temporarily avoids having to write #fileID in Swift.swiftinterface.
280285
# see also 327ea8bce2d1107a847d444651b19ca6a2901c9e
281286
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -enable-experimental-concise-pound-file>"
@@ -295,16 +300,6 @@ if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
295300
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xllvm -sil-partial-specialization>")
296301
endif()
297302

298-
target_compile_definitions(swiftCore
299-
PRIVATE
300-
$<$<BOOL:${SwiftCore_ENABLE_REFLECTION}>:-DSWIFT_ENABLE_REFLECTION>
301-
$<$<BOOL:${SwiftCore_ENABLE_COMPACT_ABSOLUTE_FUNCTION_POINTERS}>:-DSWIFT_COMPACT_ABSOLUTE_FUNCTION_POINTER>
302-
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_TARGET_LIBRARY_NAME=swiftCore>
303-
INTERFACE
304-
$<$<BOOL:${SwiftCore_ENABLE_VECTOR_TYPES}>:-DSWIFT_STDLIB_ENABLE_VECTOR_TYPES>)
305-
target_compile_options(swiftCore PRIVATE
306-
"$<$<AND:$<BOOL:${BUILD_SHARED_LIBS}>,$<COMPILE_LANGUAGE:Swift>>:SHELL:-Xcc -DswiftCore_EXPORTS>")
307-
308303
target_link_libraries(swiftCore
309304
PRIVATE
310305
swiftRuntime
@@ -315,8 +310,7 @@ target_link_libraries(swiftCore
315310
$<$<NOT:$<PLATFORM_ID:Darwin>>:swiftrt$<$<PLATFORM_ID:Windows>:T>>
316311
PUBLIC
317312
swiftShims)
318-
target_link_options(swiftCore PUBLIC
319-
$<$<LINK_LANGUAGE:Swift>:-nostartfiles>)
313+
320314
string(TOLOWER "${SwiftCore_OBJECT_FORMAT}" SwiftCore_OBJECT_FORMAT_lc)
321315
if("${SwiftCore_OBJECT_FORMAT_lc}" STREQUAL "elf")
322316
target_link_libraries(swiftCore INTERFACE
@@ -325,6 +319,10 @@ elseif("${SwiftCore_OBJECT_FORMAT_lc}" STREQUAL "coff")
325319
target_link_libraries(swiftCore INTERFACE
326320
swiftrt$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:T>)
327321
endif()
322+
323+
target_link_options(swiftCore PUBLIC
324+
$<$<LINK_LANGUAGE:Swift>:-nostartfiles>)
325+
328326
if(NOT POLICY CMP0157)
329327
target_compile_options(swiftCore PRIVATE
330328
$<TARGET_OBJECTS:swiftRuntime>
@@ -339,6 +337,10 @@ if(NOT ANDROID AND NOT APPLE AND NOT LINUX AND NOT WIN32 AND UNIX)
339337
target_link_libraries(swiftCore PRIVATE "${EXECINFO_LIBRARY}")
340338
endif()
341339

340+
if(APPLE AND BUILD_SHARED_LIBS)
341+
target_link_options(swiftCore PRIVATE "SHELL:-Xlinker -headerpad_max_install_names")
342+
endif()
343+
342344
install(TARGETS swiftCore
343345
EXPORT SwiftCoreTargets
344346
COMPONENT SwiftCore_runtime

0 commit comments

Comments
 (0)