@@ -451,12 +451,21 @@ function(_compile_swift_files
451
451
452
452
# Then we can compile both the object files and the swiftmodule files
453
453
# in parallel in this target for the object file, and ...
454
+
455
+ # Windows doesn't support long command line paths, of 8191 chars or over.
456
+ # We need to work around this by avoiding long command line arguments. This can be
457
+ # achieved by writing the list of file paths to a file, then reading that list
458
+ # in the Python script.
459
+ string (RANDOM file_name )
460
+ set (file_path "${CMAKE_CURRENT_BINARY_DIR} /${file_name} .txt" )
461
+ file (WRITE "${file_path} " "${source_files} " )
462
+
454
463
add_custom_command_target (
455
464
dependency_target
456
465
COMMAND
457
- "${PYTHON_EXECUTABLE} " "${line_directive_tool} " "${source_files } " --
466
+ "${PYTHON_EXECUTABLE} " "${line_directive_tool} " "@ ${file_path } " --
458
467
"${swift_compiler_tool} " "${main_command} " ${swift_flags}
459
- ${output_option} ${embed_bitcode_option} "${source_files } "
468
+ ${output_option} ${embed_bitcode_option} "@ ${file_path } "
460
469
${command_touch_standard_outputs}
461
470
OUTPUT ${standard_outputs}
462
471
DEPENDS
@@ -485,9 +494,9 @@ function(_compile_swift_files
485
494
add_custom_command_target (
486
495
module_dependency_target
487
496
COMMAND
488
- "${PYTHON_EXECUTABLE} " "${line_directive_tool} " "${source_files } " --
497
+ "${PYTHON_EXECUTABLE} " "${line_directive_tool} " "@ ${file_path } " --
489
498
"${swift_compiler_tool} " "-emit-module" "-o" "${module_file} " ${swift_flags}
490
- "${source_files } "
499
+ "@ ${file_path } "
491
500
${command_touch_module_outputs}
492
501
OUTPUT ${module_outputs}
493
502
DEPENDS
@@ -502,9 +511,9 @@ function(_compile_swift_files
502
511
add_custom_command_target (
503
512
sib_dependency_target
504
513
COMMAND
505
- "${PYTHON_EXECUTABLE} " "${line_directive_tool} " "${source_files } " --
514
+ "${PYTHON_EXECUTABLE} " "${line_directive_tool} " "@ ${file_path } " --
506
515
"${swift_compiler_tool} " "-emit-sib" "-o" "${sib_file} " ${swift_flags} -Onone
507
- "${source_files } "
516
+ "@ ${file_path } "
508
517
${command_touch_sib_outputs}
509
518
OUTPUT ${sib_outputs}
510
519
DEPENDS
@@ -518,9 +527,9 @@ function(_compile_swift_files
518
527
add_custom_command_target (
519
528
sibopt_dependency_target
520
529
COMMAND
521
- "${PYTHON_EXECUTABLE} " "${line_directive_tool} " "${source_files } " --
530
+ "${PYTHON_EXECUTABLE} " "${line_directive_tool} " "@ ${file_path } " --
522
531
"${swift_compiler_tool} " "-emit-sib" "-o" "${sibopt_file} " ${swift_flags} -O
523
- "${source_files } "
532
+ "@ ${file_path } "
524
533
${command_touch_sibopt_outputs}
525
534
OUTPUT ${sibopt_outputs}
526
535
DEPENDS
@@ -535,9 +544,9 @@ function(_compile_swift_files
535
544
add_custom_command_target (
536
545
sibgen_dependency_target
537
546
COMMAND
538
- "${PYTHON_EXECUTABLE} " "${line_directive_tool} " "${source_files } " --
547
+ "${PYTHON_EXECUTABLE} " "${line_directive_tool} " "@ ${file_path } " --
539
548
"${swift_compiler_tool} " "-emit-sibgen" "-o" "${sibgen_file} " ${swift_flags}
540
- "${source_files } "
549
+ "@ ${file_path } "
541
550
${command_touch_sibgen_outputs}
542
551
OUTPUT ${sibgen_outputs}
543
552
DEPENDS
0 commit comments