@@ -4,7 +4,7 @@ include(CMakeParseArguments)
4
4
function (add_swift_target target )
5
5
set (options LIBRARY)
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
@@ -25,6 +25,9 @@ function(add_swift_target target)
25
25
if (AST_MODULE_CACHE_PATH)
26
26
list (APPEND flags -module-cache -path ;${AST_MODULE_CACHE_PATH} )
27
27
endif ()
28
+ if (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
29
+ list (APPEND flags -g)
30
+ endif ()
28
31
if (AST_SWIFT_FLAGS)
29
32
foreach (flag ${AST_SWIFT_FLAGS} )
30
33
list (APPEND flags ${flag} )
@@ -78,6 +81,7 @@ function(add_swift_target target)
78
81
${doc}
79
82
DEPENDS
80
83
${source}
84
+ ${AST_DEPENDS}
81
85
COMMAND
82
86
${CMAKE_SWIFT_COMPILER} -frontend ${flags} -emit-module-path ${mod} -emit-module-doc -path ${doc} -o ${obj} -c ${all_sources} )
83
87
@@ -100,6 +104,7 @@ function(add_swift_target target)
100
104
DEPENDS
101
105
${mods}
102
106
${docs}
107
+ ${AST_DEPENDS}
103
108
COMMAND
104
109
${CMAKE_SWIFT_COMPILER} -frontend ${flags} -sil-merge-partial-modules -emit-module ${mods} -o ${module} -emit-module-doc -path ${documentation} )
105
110
endif ()
@@ -111,16 +116,35 @@ function(add_swift_target target)
111
116
${AST_OUTPUT}
112
117
DEPENDS
113
118
${objs}
119
+ ${AST_DEPENDS}
114
120
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} )
118
122
add_custom_target (${target}
119
123
ALL
120
124
DEPENDS
121
125
${AST_OUTPUT}
122
126
${module}
123
127
${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 ()
124
148
endfunction ()
125
149
126
150
function (add_swift_library library)
0 commit comments