Skip to content

Commit 7f2a763

Browse files
committed
Eliminate duplicated create_dirs
1 parent 941fc8d commit 7f2a763

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -844,13 +844,17 @@ function(_compile_swift_files
844844
endif()
845845
endif()
846846

847-
# First generate the obj dirs
847+
# First generate the obj dirs if not created before
848848
list(REMOVE_DUPLICATES dirs_to_create)
849-
add_custom_command_target(
850-
create_dirs_dependency_target
851-
COMMAND "${CMAKE_COMMAND}" -E make_directory ${dirs_to_create}
852-
OUTPUT ${dirs_to_create}
853-
COMMENT "Generating dirs for ${first_output}")
849+
list(REMOVE_ITEM dirs_to_create ${CREATED_OBJ_DIRS})
850+
if(NOT dirs_to_create STREQUAL "")
851+
add_custom_command_target(
852+
create_dirs_dependency_target
853+
COMMAND "${CMAKE_COMMAND}" -E make_directory ${dirs_to_create}
854+
OUTPUT ${dirs_to_create}
855+
COMMENT "Generating dirs for ${first_output}")
856+
set(CREATED_OBJ_DIRS ${CREATED_OBJ_DIRS} ${dirs_to_create} CACHE INTERNAL "Already created obj directories")
857+
endif()
854858

855859
# Then we can compile both the object files and the swiftmodule files
856860
# in parallel in this target for the object file, and ...

0 commit comments

Comments
 (0)