Skip to content

Commit eb9667e

Browse files
committed
build: ensure that dependencies are tracked properly
Use `add_custom_command` and `add_custom_target`. This ensures that the ordering dependencies are properly honoured by ninja. This fixes an issue where sometimes I would see `swiftDispatch` being built prior to the module map symlinks being established.
1 parent e245cbe commit eb9667e

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

CMakeLists.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,20 +247,26 @@ if(leaks_EXECUTABLE)
247247
endif()
248248

249249
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
250-
add_custom_target(module-map-symlinks
251-
ALL
252-
COMMAND
253-
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/dispatch/darwin/module.modulemap" "${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
254-
COMMAND
255-
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/private/darwin/module.modulemap" "${CMAKE_SOURCE_DIR}/private/module.modulemap")
250+
add_custom_command(OUTPUT
251+
"${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
252+
"${CMAKE_SOURCE_DIR}/private/module.modulemap"
253+
COMMAND
254+
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/dispatch/darwin/module.modulemap" "${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
255+
COMMAND
256+
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/private/darwin/module.modulemap" "${CMAKE_SOURCE_DIR}/private/module.modulemap")
256257
else()
257-
add_custom_target(module-map-symlinks
258-
ALL
259-
COMMAND
260-
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/dispatch/generic/module.modulemap" "${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
261-
COMMAND
262-
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/private/generic/module.modulemap" "${CMAKE_SOURCE_DIR}/private/module.modulemap")
258+
add_custom_command(OUTPUT
259+
"${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
260+
"${CMAKE_SOURCE_DIR}/private/module.modulemap"
261+
COMMAND
262+
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/dispatch/generic/module.modulemap" "${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
263+
COMMAND
264+
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/private/generic/module.modulemap" "${CMAKE_SOURCE_DIR}/private/module.modulemap")
263265
endif()
266+
add_custom_target(module-map-symlinks
267+
DEPENDS
268+
"${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
269+
"${CMAKE_SOURCE_DIR}/private/module.modulemap")
264270
configure_file("${CMAKE_SOURCE_DIR}/cmake/config.h.in"
265271
"${CMAKE_BINARY_DIR}/config/config_ac.h")
266272
add_definitions(-DHAVE_CONFIG_H)

0 commit comments

Comments
 (0)