From: Stefan Granitz Date: Fri, 4 Jan 2019 09:22:32 +0000 (+0000) Subject: [CMake] Use XCODE_ATTRIBUTE properties for code signing and entitlements in Xcode X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9128e2a74de4fb5c2b530a1aad1480b6787105dd;p=llvm [CMake] Use XCODE_ATTRIBUTE properties for code signing and entitlements in Xcode Summary: A post-commit comment to D55116 amended that this was the correct way for code signing in Xcode. Reviewers: beanz Reviewed By: beanz Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D55816 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350383 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index baf52c1fe75..9b7d24184fe 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -1620,7 +1620,16 @@ function(llvm_codesign name) return() endif() - if(APPLE) + if(CMAKE_GENERATOR STREQUAL "Xcode") + set_target_properties(${name} PROPERTIES + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${LLVM_CODESIGNING_IDENTITY} + ) + if(DEFINED ARG_ENTITLEMENTS) + set_target_properties(${name} PROPERTIES + XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${ARG_ENTITLEMENTS} + ) + endif() + elseif(APPLE) if(NOT CMAKE_CODESIGN) set(CMAKE_CODESIGN xcrun codesign) endif() @@ -1634,18 +1643,13 @@ function(llvm_codesign name) if(DEFINED ARG_ENTITLEMENTS) set(pass_entitlements --entitlements ${ARG_ENTITLEMENTS}) endif() - if(CMAKE_GENERATOR STREQUAL "Xcode") - # Avoid double-signing error: Since output overwrites input, Xcode runs - # the post-build rule even if the actual build-step was skipped. - set(pass_force --force) - endif() add_custom_command( TARGET ${name} POST_BUILD COMMAND ${CMAKE_COMMAND} -E env CODESIGN_ALLOCATE=${CMAKE_CODESIGN_ALLOCATE} ${CMAKE_CODESIGN} -s ${LLVM_CODESIGNING_IDENTITY} - ${pass_entitlements} ${pass_force} $ + ${pass_entitlements} $ ) endif() endfunction()