@@ -4,13 +4,12 @@ include(macCatalystUtils)
44function (force_add_dependencies TARGET )
55 foreach (DEPENDENCY ${ARGN} )
66 string (REGEX REPLACE [<>:\"/\\|?*] _ sanitized ${DEPENDENCY} )
7- add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /forced-${sanitized} -dep.swift
8- COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR} /forced-${sanitized} -dep.swift
7+ set (depfile "${CMAKE_CURRENT_BINARY_DIR} /forced-${sanitized} -dep.swift" )
8+ add_custom_command (OUTPUT ${depfile}
9+ COMMAND ${CMAKE_COMMAND} -E touch ${depfile}
910 DEPENDS ${DEPENDENCY}
1011 )
11- target_sources (${TARGET} PRIVATE
12- ${CMAKE_CURRENT_BINARY_DIR} /forced-${sanitized} -dep.swift
13- )
12+ target_sources (${TARGET} PRIVATE ${depfile} )
1413 endforeach ()
1514endfunction ()
1615
@@ -218,15 +217,6 @@ function(add_pure_swift_host_library name)
218217 # Depends on all '*.h' files in 'include/module.modulemap'.
219218 force_add_dependencies(${name} importedHeaderDependencies)
220219
221- # Workaround to touch the library and its objects so that we don't
222- # continually rebuild (again, see corresponding change in swift-syntax).
223- add_custom_command (
224- TARGET ${name}
225- POST_BUILD
226- COMMAND "${CMAKE_COMMAND} " -E touch_nocreate $<TARGET_FILE:${name} > $<TARGET_OBJECTS:${name} > "${SWIFT_HOST_LIBRARIES_DEST_DIR} /${name} .swiftmodule" "${CMAKE_CURRENT_BINARY_DIR} /${name} .swiftmodule"
227- COMMAND_EXPAND_LISTS
228- COMMENT "Update mtime of library outputs workaround" )
229-
230220 # Link against dependencies.
231221 target_link_libraries (${name} PUBLIC
232222 ${APSHL_DEPENDENCIES}
@@ -236,15 +226,7 @@ function(add_pure_swift_host_library name)
236226 ${APSHL_SWIFT_DEPENDENCIES}
237227 )
238228
239- # Make sure we can use the host libraries.
240- target_include_directories (${name} PUBLIC
241- "${SWIFT_HOST_LIBRARIES_DEST_DIR} " )
242- target_link_directories (${name} PUBLIC
243- "${SWIFT_HOST_LIBRARIES_DEST_DIR} " )
244-
245229 if (APSHL_EMIT_MODULE)
246- # Determine where Swift modules will be built and installed.
247-
248230 set (module_triple "${SWIFT_HOST_MODULE_TRIPLE} " )
249231 set (module_dir "${SWIFT_HOST_LIBRARIES_DEST_DIR} " )
250232 set (module_base "${module_dir} /${name} .swiftmodule" )
@@ -253,14 +235,6 @@ function(add_pure_swift_host_library name)
253235 set (module_private_interface_file "${module_base} /${module_triple} .private.swiftinterface" )
254236 set (module_sourceinfo_file "${module_base} /${module_triple} .swiftsourceinfo" )
255237
256- set_target_properties (${name} PROPERTIES
257- # Set the default module name to the target name.
258- Swift_MODULE_NAME ${name}
259- # Install the Swift module into the appropriate location.
260- Swift_MODULE_DIRECTORY ${module_dir}
261- # NOTE: workaround for CMake not setting up include flags.
262- INTERFACE_INCLUDE_DIRECTORIES ${module_dir} )
263-
264238 # Create the module directory.
265239 add_custom_command (
266240 TARGET ${name}
@@ -280,12 +254,27 @@ function(add_pure_swift_host_library name)
280254 >)
281255 else ()
282256 # Emit a swiftmodule in the current directory.
283- set_target_properties (${name} PROPERTIES
284- Swift_MODULE_NAME ${name}
285- Swift_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
286- set (module_file "${CMAKE_CURRENT_BINARY_DIR} /${name} .swiftmodule" )
257+ set (module_dir "${CMAKE_CURRENT_BINARY_DIR} /modules" )
258+ set (module_file "${module_dir} /${name} .swiftmodule" )
287259 endif ()
288260
261+ set_target_properties (${name} PROPERTIES
262+ # Set the default module name to the target name.
263+ Swift_MODULE_NAME ${name}
264+ # Install the Swift module into the appropriate location.
265+ Swift_MODULE_DIRECTORY ${module_dir}
266+ # NOTE: workaround for CMake not setting up include flags.
267+ INTERFACE_INCLUDE_DIRECTORIES ${module_dir} )
268+
269+ # Workaround to touch the library and its objects so that we don't
270+ # continually rebuild (again, see corresponding change in swift-syntax).
271+ add_custom_command (
272+ TARGET ${name}
273+ POST_BUILD
274+ COMMAND "${CMAKE_COMMAND} " -E touch_nocreate $<TARGET_FILE:${name} > $<TARGET_OBJECTS:${name} > "${module_file} "
275+ COMMAND_EXPAND_LISTS
276+ COMMENT "Update mtime of library outputs workaround" )
277+
289278 # Downstream linking should include the swiftmodule in debug builds to allow lldb to
290279 # work correctly. Only do this on Darwin since neither gold (currently used by default
291280 # on Linux), nor the default Windows linker 'link' support '-add_ast_path'.
0 commit comments