]> granicus.if.org Git - llvm/commitdiff
[CMake] Use XCODE_ATTRIBUTE properties for code signing and entitlements in Xcode
authorStefan Granitz <stefan.graenitz@gmail.com>
Fri, 4 Jan 2019 09:22:32 +0000 (09:22 +0000)
committerStefan Granitz <stefan.graenitz@gmail.com>
Fri, 4 Jan 2019 09:22:32 +0000 (09:22 +0000)
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

cmake/modules/AddLLVM.cmake

index baf52c1fe752c80d4ddc6270d9938fff2413ab5a..9b7d24184fe03f03ab909e800f674c8582bb3644 100644 (file)
@@ -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} $<TARGET_FILE:${name}>
+              ${pass_entitlements} $<TARGET_FILE:${name}>
     )
   endif()
 endfunction()