Skip to content

Commit b2b38a4

Browse files
committed
build: pass -target to the driver when linking
This allows us to crosslink when building with CMake.
1 parent 033a5d1 commit b2b38a4

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

cmake/modules/SwiftSupport.cmake

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +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})
2728
endif()
2829
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
29-
list(APPEND flags -g)
30+
list(APPEND compile_flags -g)
3031
endif()
3132
if(AST_SWIFT_FLAGS)
3233
foreach(flag ${AST_SWIFT_FLAGS})
33-
list(APPEND flags ${flag})
34+
list(APPEND compile_flags ${flag})
3435
endforeach()
3536
endif()
3637
if(AST_CFLAGS)
3738
foreach(flag ${AST_CFLAGS})
38-
list(APPEND flags -Xcc;${flag})
39+
list(APPEND compile_flags -Xcc;${flag})
3940
endforeach()
4041
endif()
4142
if(AST_LINK_FLAGS)
@@ -83,7 +84,7 @@ function(add_swift_target target)
8384
${source}
8485
${AST_DEPENDS}
8586
COMMAND
86-
${CMAKE_SWIFT_COMPILER} -frontend ${flags} -emit-module-path ${mod} -emit-module-doc-path ${doc} -o ${obj} -c ${all_sources})
87+
${CMAKE_SWIFT_COMPILER} -frontend ${compile_flags} -emit-module-path ${mod} -emit-module-doc-path ${doc} -o ${obj} -c ${all_sources})
8788

8889
list(APPEND objs ${obj})
8990
list(APPEND mods ${mod})
@@ -106,7 +107,7 @@ function(add_swift_target target)
106107
${docs}
107108
${AST_DEPENDS}
108109
COMMAND
109-
${CMAKE_SWIFT_COMPILER} -frontend ${flags} -sil-merge-partial-modules -emit-module ${mods} -o ${module} -emit-module-doc-path ${documentation})
110+
${CMAKE_SWIFT_COMPILER} -frontend ${compile_flags} -sil-merge-partial-modules -emit-module ${mods} -o ${module} -emit-module-doc-path ${documentation})
110111
endif()
111112

112113
if(AST_LIBRARY)

0 commit comments

Comments
 (0)