Skip to content

Commit 743b4bb

Browse files
authored
Merge pull request #5586 from cooperp/fix-cmake-swiftmodule
2 parents 3e03ff4 + 43add7c commit 743b4bb

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

cmake/modules/SwiftSource.cmake

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -441,21 +441,23 @@ function(_compile_swift_files
441441
set("${dependency_target_out_var_name}" "${dependency_target}" PARENT_SCOPE)
442442

443443
# This is the target to generate the .swiftmodule and .swiftdoc
444-
add_custom_command_target(
445-
module_dependency_target
446-
COMMAND
447-
"${line_directive_tool}" "${source_files}" --
448-
"${swift_compiler_tool}" "${module_command}" ${swift_flags}
449-
"${source_files}"
450-
${command_touch_module_outputs}
451-
OUTPUT ${module_outputs}
452-
DEPENDS
453-
${swift_compiler_tool_dep}
454-
${source_files} ${SWIFTFILE_DEPENDS}
455-
${swift_ide_test_dependency} ${api_notes_dependency_target}
456-
${obj_dirs_dependency_target}
457-
COMMENT "Generating ${module_file}")
458-
set("${dependency_module_target_out_var_name}" "${module_dependency_target}" PARENT_SCOPE)
444+
if (module_file)
445+
add_custom_command_target(
446+
module_dependency_target
447+
COMMAND
448+
"${line_directive_tool}" "${source_files}" --
449+
"${swift_compiler_tool}" "${module_command}" ${swift_flags}
450+
"${source_files}"
451+
${command_touch_module_outputs}
452+
OUTPUT ${module_outputs}
453+
DEPENDS
454+
${swift_compiler_tool_dep}
455+
${source_files} ${SWIFTFILE_DEPENDS}
456+
${swift_ide_test_dependency} ${api_notes_dependency_target}
457+
${obj_dirs_dependency_target}
458+
COMMENT "Generating ${module_file}")
459+
set("${dependency_module_target_out_var_name}" "${module_dependency_target}" PARENT_SCOPE)
460+
endif()
459461

460462
# Make sure the build system knows the file is a generated object file.
461463
set_source_files_properties(${SWIFTFILE_OUTPUT}

0 commit comments

Comments
 (0)