@@ -283,17 +283,10 @@ function(_compile_swift_files
283
283
284
284
list (APPEND swift_flags ${SWIFTFILE_FLAGS} )
285
285
286
- set (obj_dirs )
286
+ set (dirs_to_create )
287
287
foreach (output ${SWIFTFILE_OUTPUT} )
288
288
get_filename_component (objdir "${output} " PATH )
289
- list (APPEND obj_dirs "${objdir} " )
290
- endforeach ()
291
- list (REMOVE_DUPLICATES obj_dirs )
292
-
293
- set (command_create_dirs )
294
- foreach (objdir ${obj_dirs} )
295
- list (APPEND command_create_dirs
296
- COMMAND "${CMAKE_COMMAND} " -E make_directory "${objdir} " )
289
+ list (APPEND dirs_to_create "${objdir} " )
297
290
endforeach ()
298
291
299
292
set (module_file )
@@ -333,11 +326,9 @@ function(_compile_swift_files
333
326
endif ()
334
327
335
328
if (SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS )
336
- list (APPEND command_create_dirs
337
- COMMAND "${CMAKE_COMMAND} " -E make_directory "${specific_module_dir} " )
329
+ list (APPEND dirs_to_create "${specific_module_dir} " )
338
330
else ()
339
- list (APPEND command_create_dirs
340
- COMMAND "${CMAKE_COMMAND} " -E make_directory "${module_dir} " )
331
+ list (APPEND dirs_to_create "${module_dir} " )
341
332
endif ()
342
333
343
334
# If we have extra regexp flags, check if we match any of the regexps. If so
@@ -398,7 +389,7 @@ function(_compile_swift_files
398
389
endif ()
399
390
400
391
if (SWIFT_REPORT_STATISTICS )
401
- list (GET obj_dirs 0 first_obj_dir )
392
+ list (GET dirs_to_create 0 first_obj_dir )
402
393
list (APPEND swift_flags "-stats-output-dir" ${first_obj_dir} )
403
394
endif ()
404
395
@@ -433,12 +424,12 @@ function(_compile_swift_files
433
424
endif ()
434
425
435
426
# First generate the obj dirs
427
+ list (REMOVE_DUPLICATES dirs_to_create )
436
428
add_custom_command_target (
437
- obj_dirs_dependency_target
438
- ${command_create_dirs}
439
- COMMAND ""
440
- OUTPUT ${obj_dirs}
441
- COMMENT "Generating obj dirs for ${first_output} " )
429
+ create_dirs_dependency_target
430
+ COMMAND "${CMAKE_COMMAND} " -E make_directory ${dirs_to_create}
431
+ OUTPUT ${dirs_to_create}
432
+ COMMENT "Generating dirs for ${first_output} " )
442
433
443
434
# Then we can compile both the object files and the swiftmodule files
444
435
# in parallel in this target for the object file, and ...
@@ -478,7 +469,7 @@ function(_compile_swift_files
478
469
${swift_compiler_tool_dep}
479
470
${file_path} ${source_files} ${SWIFTFILE_DEPENDS}
480
471
${swift_ide_test_dependency}
481
- ${obj_dirs_dependency_target }
472
+ ${create_dirs_dependency_target }
482
473
${copy_legacy_layouts_dep}
483
474
COMMENT "Compiling ${first_output} " )
484
475
set ("${dependency_target_out_var_name} " "${dependency_target} " PARENT_SCOPE )
@@ -513,7 +504,7 @@ function(_compile_swift_files
513
504
${swift_compiler_tool_dep}
514
505
${source_files} ${SWIFTFILE_DEPENDS}
515
506
${swift_ide_test_dependency}
516
- ${obj_dirs_dependency_target }
507
+ ${create_dirs_dependency_target }
517
508
COMMENT "Generating ${module_file} " )
518
509
set ("${dependency_module_target_out_var_name} " "${module_dependency_target} " PARENT_SCOPE )
519
510
@@ -529,7 +520,7 @@ function(_compile_swift_files
529
520
DEPENDS
530
521
${swift_compiler_tool_dep}
531
522
${source_files} ${SWIFTFILE_DEPENDS}
532
- ${obj_dirs_dependency_target }
523
+ ${create_dirs_dependency_target }
533
524
COMMENT "Generating ${sib_file} "
534
525
EXCLUDE_FROM_ALL )
535
526
set ("${dependency_sib_target_out_var_name} " "${sib_dependency_target} " PARENT_SCOPE )
@@ -545,7 +536,7 @@ function(_compile_swift_files
545
536
DEPENDS
546
537
${swift_compiler_tool_dep}
547
538
${source_files} ${SWIFTFILE_DEPENDS}
548
- ${obj_dirs_dependency_target }
539
+ ${create_dirs_dependency_target }
549
540
COMMENT "Generating ${sibopt_file} "
550
541
EXCLUDE_FROM_ALL )
551
542
set ("${dependency_sibopt_target_out_var_name} " "${sibopt_dependency_target} " PARENT_SCOPE )
@@ -562,7 +553,7 @@ function(_compile_swift_files
562
553
DEPENDS
563
554
${swift_compiler_tool_dep}
564
555
${source_files} ${SWIFTFILE_DEPENDS}
565
- ${obj_dirs_dependency_target }
556
+ ${create_dirs_dependency_target }
566
557
COMMENT "Generating ${sibgen_file} "
567
558
EXCLUDE_FROM_ALL )
568
559
set ("${dependency_sibgen_target_out_var_name} " "${sibgen_dependency_target} " PARENT_SCOPE )
0 commit comments