@@ -4,7 +4,7 @@ include(CMakeParseArguments)
4
4
function (add_swift_target target )
5
5
set (options LIBRARY;SHARED;STATIC )
6
6
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 )
8
8
9
9
cmake_parse_arguments (AST "${options} " "${single_value_options} " "${multiple_value_options} " ${ARGN} )
10
10
@@ -70,6 +70,11 @@ function(add_swift_target target)
70
70
set (AST_OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /${target}.dir/${target}${CMAKE_EXECUTABLE_SUFFIX} )
71
71
endif ()
72
72
endif ()
73
+ if (CMAKE_SYSTEM_NAME STREQUAL Windows )
74
+ if (AST_SHARED OR BUILD_SHARED_LIBS )
75
+ set (IMPORT_LIBRARY ${CMAKE_CURRENT_BINARY_DIR} /${target}.dir/${CMAKE_IMPORT_LIBRARY_PREFIX}${target}${CMAKE_IMPORT_LIBRARY_SUFFIX} )
76
+ endif ()
77
+ endif ()
73
78
74
79
set (sources )
75
80
foreach (source ${AST_SOURCES} )
@@ -132,16 +137,14 @@ function(add_swift_target target)
132
137
if (AST_LIBRARY )
133
138
set (emit_library -emit-library )
134
139
endif ()
135
- if (library_kind STREQUAL SHARED )
140
+ if (NOT AST_LIBRARY OR library_kind STREQUAL SHARED )
136
141
add_custom_command (OUTPUT
137
142
${AST_OUTPUT}
138
143
DEPENDS
139
144
${objs}
140
145
${AST_DEPENDS}
141
146
COMMAND
142
- ${CMAKE_SWIFT_COMPILER} ${emit_library} ${link_flags} -o ${AST_OUTPUT} ${objs}
143
- COMMAND
144
- ${CMAKE_COMMAND} -E copy ${AST_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR} )
147
+ ${CMAKE_SWIFT_COMPILER} ${emit_library} ${link_flags} -o ${AST_OUTPUT} ${objs} )
145
148
add_custom_target (${target}
146
149
ALL
147
150
DEPENDS
@@ -150,6 +153,7 @@ function(add_swift_target target)
150
153
${documentation} )
151
154
else ()
152
155
add_library (${target} -static STATIC ${objs} )
156
+ add_dependencies (${target} -static ${AST_DEPENDS} )
153
157
get_filename_component (ast_output_bn ${AST_OUTPUT} NAME )
154
158
get_filename_component (ast_output_dn ${AST_OUTPUT} DIRECTORY )
155
159
set_target_properties (${target} -static
@@ -164,6 +168,35 @@ function(add_swift_target target)
164
168
${module}
165
169
${documentation} )
166
170
endif ()
171
+
172
+ if (AST_RESOURCES )
173
+ add_custom_command (TARGET
174
+ ${target}
175
+ POST_BUILD
176
+ COMMAND
177
+ ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR} /${target}
178
+ COMMAND
179
+ ${CMAKE_COMMAND} -E copy ${AST_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR} /${target}
180
+ COMMAND
181
+ ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR} /${target}/Resources
182
+ COMMAND
183
+ ${CMAKE_COMMAND} -E copy ${AST_RESOURCES} ${CMAKE_CURRENT_BINARY_DIR} /${target}/Resources )
184
+ else ()
185
+ add_custom_command (TARGET
186
+ ${target}
187
+ POST_BUILD
188
+ COMMAND
189
+ ${CMAKE_COMMAND} -E copy ${AST_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR} )
190
+ if (CMAKE_SYSTEM_NAME STREQUAL Windows )
191
+ if (AST_SHARED OR BUILD_SHARED_LIBS )
192
+ add_custom_command (TARGET
193
+ ${target}
194
+ POST_BUILD
195
+ COMMAND
196
+ ${CMAKE_COMMAND} -E copy ${IMPORT_LIBRARY} ${CMAKE_CURRENT_BINARY_DIR} )
197
+ endif ()
198
+ endif ()
199
+ endif ()
167
200
endfunction ()
168
201
169
202
function (add_swift_library library )
0 commit comments