Skip to content

Commit 033a5d1

Browse files
authored
Merge pull request #227 from apple/dependency
build: synchronize SwiftSupport with Foundation
2 parents 69667e5 + b2e1096 commit 033a5d1

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

cmake/modules/SwiftSupport.cmake

+28-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include(CMakeParseArguments)
44
function(add_swift_target target)
55
set(options LIBRARY)
66
set(single_value_options MODULE_NAME;MODULE_LINK_NAME;MODULE_PATH;MODULE_CACHE_PATH;OUTPUT;TARGET)
7-
set(multiple_value_options CFLAGS;DEPENDS;LINK_FLAGS;SOURCES;SWIFT_FLAGS)
7+
set(multiple_value_options CFLAGS;DEPENDS;LINK_FLAGS;RESOURCES;SOURCES;SWIFT_FLAGS)
88

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

@@ -25,6 +25,9 @@ function(add_swift_target target)
2525
if(AST_MODULE_CACHE_PATH)
2626
list(APPEND flags -module-cache-path;${AST_MODULE_CACHE_PATH})
2727
endif()
28+
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
29+
list(APPEND flags -g)
30+
endif()
2831
if(AST_SWIFT_FLAGS)
2932
foreach(flag ${AST_SWIFT_FLAGS})
3033
list(APPEND flags ${flag})
@@ -78,6 +81,7 @@ function(add_swift_target target)
7881
${doc}
7982
DEPENDS
8083
${source}
84+
${AST_DEPENDS}
8185
COMMAND
8286
${CMAKE_SWIFT_COMPILER} -frontend ${flags} -emit-module-path ${mod} -emit-module-doc-path ${doc} -o ${obj} -c ${all_sources})
8387

@@ -100,6 +104,7 @@ function(add_swift_target target)
100104
DEPENDS
101105
${mods}
102106
${docs}
107+
${AST_DEPENDS}
103108
COMMAND
104109
${CMAKE_SWIFT_COMPILER} -frontend ${flags} -sil-merge-partial-modules -emit-module ${mods} -o ${module} -emit-module-doc-path ${documentation})
105110
endif()
@@ -111,16 +116,35 @@ function(add_swift_target target)
111116
${AST_OUTPUT}
112117
DEPENDS
113118
${objs}
119+
${AST_DEPENDS}
114120
COMMAND
115-
${CMAKE_SWIFT_COMPILER} ${emit_library} ${link_flags} -o ${AST_OUTPUT} ${objs}
116-
COMMAND
117-
${CMAKE_COMMAND} -E copy ${AST_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR})
121+
${CMAKE_SWIFT_COMPILER} ${emit_library} ${link_flags} -o ${AST_OUTPUT} ${objs})
118122
add_custom_target(${target}
119123
ALL
120124
DEPENDS
121125
${AST_OUTPUT}
122126
${module}
123127
${documentation})
128+
129+
if(AST_RESOURCES)
130+
add_custom_command(TARGET
131+
${target}
132+
POST_BUILD
133+
COMMAND
134+
${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${target}
135+
COMMAND
136+
${CMAKE_COMMAND} -E copy ${AST_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${target}
137+
COMMAND
138+
${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${target}/Resources
139+
COMMAND
140+
${CMAKE_COMMAND} -E copy ${AST_RESOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${target}/Resources)
141+
else()
142+
add_custom_command(TARGET
143+
${target}
144+
POST_BUILD
145+
COMMAND
146+
${CMAKE_COMMAND} -E copy ${AST_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR})
147+
endif()
124148
endfunction()
125149

126150
function(add_swift_library library)

0 commit comments

Comments
 (0)