| 1 |
function(xcode_sign_adhoc target) |
| 2 |
if(CMAKE_GENERATOR STREQUAL "Xcode" AND |
| 3 |
"${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64") |
| 4 |
if(XCODE_VERSION VERSION_GREATER_EQUAL 15) |
| 5 |
# Xcode 15+ enforces '-Xlinker -no_adhoc_codesign' after user flags, |
| 6 |
# so we cannot convince the linker to add an adhoc signature. |
| 7 |
add_custom_command(TARGET ${target} POST_BUILD COMMAND codesign --sign - --force "$<TARGET_FILE:${target}>") |
| 8 |
else() |
| 9 |
# Xcode runs POST_BUILD before signing, so let the linker use ad-hoc signing. |
| 10 |
# See CMake Issue 21845. |
| 11 |
target_link_options(${target} PRIVATE LINKER:-adhoc_codesign) |
| 12 |
endif() |
| 13 |
endif() |
| 14 |
endfunction() |