@@ -49,9 +49,9 @@ function(handle_swift_sources
49
49
dependency_sibgen_target_out_var_name
50
50
sourcesvar externalvar name )
51
51
cmake_parse_arguments (SWIFTSOURCES
52
- "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC;NO_LINK_NAME;IS_FRAGILE"
52
+ "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC;NO_LINK_NAME;IS_FRAGILE;ONLY_SWIFTMODULE "
53
53
"SDK;ARCHITECTURE;INSTALL_IN_COMPONENT;MACCATALYST_BUILD_FLAVOR;BOOTSTRAPPING"
54
- "DEPENDS;COMPILE_FLAGS;MODULE_NAME;ENABLE_LTO"
54
+ "DEPENDS;COMPILE_FLAGS;MODULE_NAME;MODULE_DIR; ENABLE_LTO"
55
55
${ARGN} )
56
56
translate_flag (${SWIFTSOURCES_IS_MAIN} "IS_MAIN" IS_MAIN_arg )
57
57
translate_flag (${SWIFTSOURCES_IS_STDLIB} "IS_STDLIB" IS_STDLIB_arg )
@@ -65,6 +65,7 @@ function(handle_swift_sources
65
65
STATIC_arg )
66
66
translate_flag (${SWIFTSOURCES_NO_LINK_NAME} "NO_LINK_NAME" NO_LINK_NAME_arg )
67
67
translate_flag (${SWIFTSOURCES_IS_FRAGILE} "IS_FRAGILE" IS_FRAGILE_arg )
68
+ translate_flag (${SWIFTSOURCES_ONLY_SWIFTMODULE} "ONLY_SWIFTMODULE" ONLY_SWIFTMODULE_arg )
68
69
if (DEFINED SWIFTSOURCES_BOOTSTRAPPING )
69
70
set (BOOTSTRAPPING_arg "BOOTSTRAPPING" ${SWIFTSOURCES_BOOTSTRAPPING} )
70
71
endif ()
@@ -146,6 +147,7 @@ function(handle_swift_sources
146
147
SDK ${SWIFTSOURCES_SDK}
147
148
ARCHITECTURE ${SWIFTSOURCES_ARCHITECTURE}
148
149
MODULE_NAME ${SWIFTSOURCES_MODULE_NAME}
150
+ MODULE_DIR ${SWIFTSOURCES_MODULE_DIR}
149
151
${IS_MAIN_arg}
150
152
${IS_STDLIB_arg}
151
153
${IS_STDLIB_CORE_arg}
@@ -154,6 +156,7 @@ function(handle_swift_sources
154
156
${STATIC_arg}
155
157
${BOOTSTRAPPING_arg}
156
158
${IS_FRAGILE_arg}
159
+ ${ONLY_SWIFTMODULE_arg}
157
160
INSTALL_IN_COMPONENT "${SWIFTSOURCES_INSTALL_IN_COMPONENT} "
158
161
MACCATALYST_BUILD_FLAVOR "${SWIFTSOURCES_MACCATALYST_BUILD_FLAVOR} " )
159
162
set ("${dependency_target_out_var_name} " "${dependency_target} " PARENT_SCOPE )
@@ -378,7 +381,7 @@ function(_compile_swift_files
378
381
dependency_sib_target_out_var_name dependency_sibopt_target_out_var_name
379
382
dependency_sibgen_target_out_var_name )
380
383
cmake_parse_arguments (SWIFTFILE
381
- "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC;IS_FRAGILE"
384
+ "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC;IS_FRAGILE;ONLY_SWIFTMODULE "
382
385
"OUTPUT;MODULE_NAME;INSTALL_IN_COMPONENT;MACCATALYST_BUILD_FLAVOR;BOOTSTRAPPING"
383
386
"SOURCES;FLAGS;DEPENDS;SDK;ARCHITECTURE;OPT_FLAGS;MODULE_DIR"
384
387
${ARGN} )
@@ -903,13 +906,7 @@ function(_compile_swift_files
903
906
endif ()
904
907
endif ()
905
908
906
- # First generate the obj dirs
907
909
list (REMOVE_DUPLICATES dirs_to_create )
908
- add_custom_command_target (
909
- create_dirs_dependency_target
910
- COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
911
- OUTPUT ${dirs_to_create}
912
- COMMENT "Generating dirs for ${first_output} " )
913
910
914
911
# Then we can compile both the object files and the swiftmodule files
915
912
# in parallel in this target for the object file, and ...
@@ -940,8 +937,10 @@ function(_compile_swift_files
940
937
set (copy_legacy_layouts_dep )
941
938
endif ()
942
939
940
+ if (NOT SWIFTFILE_ONLY_SWIFTMODULE )
943
941
add_custom_command_target (
944
942
dependency_target
943
+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
945
944
COMMAND
946
945
${set_environment_args}
947
946
"$<TARGET_FILE:Python3::Interpreter>" "${line_directive_tool} " "@${file_path} " --
@@ -955,10 +954,10 @@ function(_compile_swift_files
955
954
${swift_compiler_tool_dep}
956
955
${source_files} ${SWIFTFILE_DEPENDS}
957
956
${swift_ide_test_dependency}
958
- ${create_dirs_dependency_target}
959
957
${copy_legacy_layouts_dep}
960
958
COMMENT "Compiling ${first_output} " )
961
959
set ("${dependency_target_out_var_name} " "${dependency_target} " PARENT_SCOPE )
960
+ endif ()
962
961
963
962
# This is the target to generate:
964
963
#
@@ -978,6 +977,7 @@ function(_compile_swift_files
978
977
if (NOT SWIFTFILE_IS_MAIN )
979
978
add_custom_command_target (
980
979
module_dependency_target
980
+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
981
981
COMMAND
982
982
"${CMAKE_COMMAND} " "-E" "remove" "-f" ${module_outputs}
983
983
COMMAND
@@ -997,7 +997,6 @@ function(_compile_swift_files
997
997
${swift_compiler_tool_dep}
998
998
${source_files} ${SWIFTFILE_DEPENDS}
999
999
${swift_ide_test_dependency}
1000
- ${create_dirs_dependency_target}
1001
1000
${copy_legacy_layouts_dep}
1002
1001
COMMENT "Generating ${module_file} " )
1003
1002
@@ -1010,6 +1009,7 @@ function(_compile_swift_files
1010
1009
endif ()
1011
1010
add_custom_command_target (
1012
1011
module_dependency_target_static
1012
+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
1013
1013
COMMAND
1014
1014
"${CMAKE_COMMAND} " "-E" "make_directory" ${module_dir_static}
1015
1015
${specific_module_dir_static}
@@ -1026,7 +1026,6 @@ function(_compile_swift_files
1026
1026
${swift_compiler_tool_dep}
1027
1027
${source_files} ${SWIFTFILE_DEPENDS}
1028
1028
${swift_ide_test_dependency}
1029
- ${create_dirs_dependency_target}
1030
1029
${copy_legacy_layouts_dep}
1031
1030
COMMENT "Generating ${module_file} " )
1032
1031
set ("${dependency_module_target_out_var_name} " "${module_dependency_target_static} " PARENT_SCOPE )
@@ -1084,6 +1083,7 @@ function(_compile_swift_files
1084
1083
# This is the target to generate the .sib files. It is not built by default.
1085
1084
add_custom_command_target (
1086
1085
sib_dependency_target
1086
+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
1087
1087
COMMAND
1088
1088
${set_environment_args}
1089
1089
"$<TARGET_FILE:Python3::Interpreter>" "${line_directive_tool} " "@${file_path} " --
@@ -1096,14 +1096,14 @@ function(_compile_swift_files
1096
1096
"${file_path} "
1097
1097
${swift_compiler_tool_dep}
1098
1098
${source_files} ${SWIFTFILE_DEPENDS}
1099
- ${create_dirs_dependency_target}
1100
1099
${copy_legacy_layouts_dep}
1101
1100
COMMENT "Generating ${sib_file} "
1102
1101
EXCLUDE_FROM_ALL )
1103
1102
set ("${dependency_sib_target_out_var_name} " "${sib_dependency_target} " PARENT_SCOPE )
1104
1103
1105
1104
add_custom_command_target (
1106
1105
sibopt_dependency_target
1106
+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
1107
1107
COMMAND
1108
1108
${set_environment_args}
1109
1109
"$<TARGET_FILE:Python3::Interpreter>" "${line_directive_tool} " "@${file_path} " --
@@ -1116,7 +1116,6 @@ function(_compile_swift_files
1116
1116
"${file_path} "
1117
1117
${swift_compiler_tool_dep}
1118
1118
${source_files} ${SWIFTFILE_DEPENDS}
1119
- ${create_dirs_dependency_target}
1120
1119
${copy_legacy_layouts_dep}
1121
1120
COMMENT "Generating ${sibopt_file} "
1122
1121
EXCLUDE_FROM_ALL )
@@ -1125,6 +1124,7 @@ function(_compile_swift_files
1125
1124
# This is the target to generate the .sibgen files. It is not built by default.
1126
1125
add_custom_command_target (
1127
1126
sibgen_dependency_target
1127
+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
1128
1128
COMMAND
1129
1129
${set_environment_args}
1130
1130
"$<TARGET_FILE:Python3::Interpreter>" "${line_directive_tool} " "@${file_path} " --
@@ -1137,7 +1137,6 @@ function(_compile_swift_files
1137
1137
"${file_path} "
1138
1138
${swift_compiler_tool_dep}
1139
1139
${source_files} ${SWIFTFILE_DEPENDS}
1140
- ${create_dirs_dependency_target}
1141
1140
${copy_legacy_layouts_dep}
1142
1141
COMMENT "Generating ${sibgen_file} "
1143
1142
EXCLUDE_FROM_ALL )
0 commit comments