Skip to content

Commit 2d3cb3c

Browse files
authored
Sign executables for target Apple platforms with a post build event (#61458)
...instead of using ad hoc targets. This way executables are already signed before running tests, and this will happen even if users want to test manually with `lit.py`. Addresses rdar://66654434
1 parent 4442d1c commit 2d3cb3c

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,17 +2668,9 @@ function(add_swift_target_executable name)
26682668
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291)
26692669
set_property(TARGET ${VARIANT_NAME} PROPERTY OSX_ARCHITECTURES "${arch}")
26702670

2671-
add_custom_command_target(unused_var2
2672-
COMMAND "codesign" "-f" "-s" "-" "${SWIFT_RUNTIME_OUTPUT_INTDIR}/${VARIANT_NAME}"
2673-
CUSTOM_TARGET_NAME "${VARIANT_NAME}_signed"
2674-
OUTPUT "${SWIFT_RUNTIME_OUTPUT_INTDIR}/${VARIANT_NAME}_signed"
2675-
DEPENDS ${VARIANT_NAME})
2676-
else()
2677-
# No code signing on other platforms.
2678-
add_custom_command_target(unused_var2
2679-
CUSTOM_TARGET_NAME "${VARIANT_NAME}_signed"
2680-
OUTPUT "${SWIFT_RUNTIME_OUTPUT_INTDIR}/${VARIANT_NAME}_signed"
2681-
DEPENDS ${VARIANT_NAME})
2671+
add_custom_command(TARGET ${VARIANT_NAME}
2672+
POST_BUILD
2673+
COMMAND "codesign" "-f" "-s" "-" "${SWIFT_RUNTIME_OUTPUT_INTDIR}/${VARIANT_NAME}")
26822674
endif()
26832675
endforeach()
26842676
endforeach()

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ foreach(SDK ${SWIFT_SDKS})
308308
"swift-reflection-test${DEFAULT_OSX_VARIANT_SUFFIX}")
309309
else()
310310
list(APPEND test_dependencies
311-
"swift-reflection-test${VARIANT_SUFFIX}_signed")
311+
"swift-reflection-test${VARIANT_SUFFIX}")
312312
endif()
313313
endif()
314314

0 commit comments

Comments
 (0)