Skip to content

Commit 1343096

Browse files
committed
[CMake] Fix creation of swiftmodule directories on Apple platforms (2)
The previous commit resulted in multiple targets that claimed to be able to generate the directories in question. Instead, just create the directories as a pre-build step for the targets that actually need them. (This does keep the cleanup for the existing directory creation target, though.) More https://bugs.swift.org/browse/SR-10029
1 parent 7135460 commit 1343096

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

cmake/modules/SwiftSource.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ function(_compile_swift_files
195195

196196
# Compute flags for the Swift compiler.
197197
set(swift_flags)
198+
set(swift_module_flags)
198199

199200
_add_variant_swift_compile_flags(
200201
"${SWIFTFILE_SDK}"
@@ -309,6 +310,8 @@ function(_compile_swift_files
309310
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
310311
set(specific_module_dir "${module_base}.swiftmodule")
311312
set(module_base "${module_base}.swiftmodule/${SWIFTFILE_ARCHITECTURE}")
313+
else()
314+
set(specific_module_dir)
312315
endif()
313316
set(module_file "${module_base}.swiftmodule")
314317
set(module_doc_file "${module_base}.swiftdoc")
@@ -321,14 +324,8 @@ function(_compile_swift_files
321324

322325
if(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES)
323326
set(interface_file "${module_base}.swiftinterface")
324-
list(APPEND swift_flags
325-
"-emit-parseable-module-interface-path" "${interface_file}")
326-
endif()
327-
328-
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
329-
list(APPEND dirs_to_create "${specific_module_dir}")
330-
else()
331-
list(APPEND dirs_to_create "${module_dir}")
327+
list(APPEND swift_module_flags
328+
"-emit-parseable-module-interface-path" "${interface_file}")
332329
endif()
333330

334331
# If we have extra regexp flags, check if we match any of the regexps. If so
@@ -494,10 +491,13 @@ function(_compile_swift_files
494491
module_dependency_target
495492
COMMAND
496493
"${CMAKE_COMMAND}" "-E" "remove" "-f" ${module_outputs}
494+
COMMAND
495+
"${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir}
496+
${specific_module_dir}
497497
COMMAND
498498
"${PYTHON_EXECUTABLE}" "${line_directive_tool}" "@${file_path}" --
499499
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}"
500-
${swift_flags} "@${file_path}"
500+
${swift_flags} ${swift_module_flags} "@${file_path}"
501501
${command_touch_module_outputs}
502502
OUTPUT ${module_outputs}
503503
DEPENDS

0 commit comments

Comments
 (0)