Skip to content

Commit 5bcd598

Browse files
Merge pull request swiftlang#427 from compnerd/cross-link
enable cross-linking/synchronise with Foundation
2 parents 09ec354 + 63e21d1 commit 5bcd598

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

cmake/modules/SwiftSupport.cmake

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,35 @@ function(add_swift_target target)
88

99
cmake_parse_arguments(AST "${options}" "${single_value_options}" "${multiple_value_options}" ${ARGN})
1010

11-
set(flags ${CMAKE_SWIFT_FLAGS})
11+
set(compile_flags ${CMAKE_SWIFT_FLAGS})
1212
set(link_flags)
1313

1414
if(AST_TARGET)
15-
list(APPEND flags -target;${AST_TARGET})
15+
list(APPEND compile_flags -target;${AST_TARGET})
16+
list(APPEND link_flags -target;${AST_TARGET})
1617
endif()
1718
if(AST_MODULE_NAME)
18-
list(APPEND flags -module-name;${AST_MODULE_NAME})
19+
list(APPEND compile_flags -module-name;${AST_MODULE_NAME})
1920
else()
20-
list(APPEND flags -module-name;${target})
21+
list(APPEND compile_flags -module-name;${target})
2122
endif()
2223
if(AST_MODULE_LINK_NAME)
23-
list(APPEND flags -module-link-name;${AST_MODULE_LINK_NAME})
24+
list(APPEND compile_flags -module-link-name;${AST_MODULE_LINK_NAME})
2425
endif()
2526
if(AST_MODULE_CACHE_PATH)
26-
list(APPEND flags -module-cache-path;${AST_MODULE_CACHE_PATH})
27+
list(APPEND compile_flags -module-cache-path;${AST_MODULE_CACHE_PATH})
28+
endif()
29+
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
30+
list(APPEND compile_flags -g)
2731
endif()
2832
if(AST_SWIFT_FLAGS)
2933
foreach(flag ${AST_SWIFT_FLAGS})
30-
list(APPEND flags ${flag})
34+
list(APPEND compile_flags ${flag})
3135
endforeach()
3236
endif()
3337
if(AST_CFLAGS)
3438
foreach(flag ${AST_CFLAGS})
35-
list(APPEND flags -Xcc;${flag})
39+
list(APPEND compile_flags -Xcc;${flag})
3640
endforeach()
3741
endif()
3842
if(AST_LINK_FLAGS)
@@ -99,7 +103,7 @@ function(add_swift_target target)
99103
${source}
100104
${AST_DEPENDS}
101105
COMMAND
102-
${CMAKE_SWIFT_COMPILER} -frontend ${flags} -emit-module-path ${mod} -emit-module-doc-path ${doc} -o ${obj} -c ${all_sources})
106+
${CMAKE_SWIFT_COMPILER} -frontend ${compile_flags} -emit-module-path ${mod} -emit-module-doc-path ${doc} -o ${obj} -c ${all_sources})
103107

104108
list(APPEND objs ${obj})
105109
list(APPEND mods ${mod})
@@ -122,7 +126,7 @@ function(add_swift_target target)
122126
${docs}
123127
${AST_DEPENDS}
124128
COMMAND
125-
${CMAKE_SWIFT_COMPILER} -frontend ${flags} -sil-merge-partial-modules -emit-module ${mods} -o ${module} -emit-module-doc-path ${documentation})
129+
${CMAKE_SWIFT_COMPILER} -frontend ${compile_flags} -sil-merge-partial-modules -emit-module ${mods} -o ${module} -emit-module-doc-path ${documentation})
126130
endif()
127131

128132
if(AST_LIBRARY)

0 commit comments

Comments
 (0)