llvm.org GIT mirror llvm / 8865b26
[CMake] Accept ENTITLEMENTS in add_llvm_executable and llvm_codesign Summary: Allow code-signing with entitlements. FORCE may be used to avoid an error when replacing existing signatures. Reviewers: beanz, bogner Reviewed By: beanz Subscribers: mgorny, llvm-commits, lldb-commits Differential Revision: https://reviews.llvm.org/D54443 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347068 91177308-0d34-0410-b5e6-96231b3b80d8 Stefan Granitz 10 months ago
2 changed file(s) with 24 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
398398 option(LLVM_EXTERNALIZE_DEBUGINFO
399399 "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
400400
401 option(LLVM_CODESIGNING_IDENTITY
402 "Sign executables and dylibs with the given identity (Darwin Only)" OFF)
401 set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING
402 "Sign executables and dylibs with the given identity or skip if empty (Darwin Only)")
403403
404404 # If enabled, verify we are on a platform that supports oprofile.
405405 if( LLVM_USE_OPROFILE )
579579
580580 if(ARG_SHARED OR ARG_MODULE)
581581 llvm_externalize_debuginfo(${name})
582 llvm_codesign(${name})
582 llvm_codesign(TARGET ${name})
583583 endif()
584584 endfunction()
585585
707707
708708
709709 macro(add_llvm_executable name)
710 cmake_parse_arguments(ARG "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH" "" "DEPENDS" ${ARGN})
710 cmake_parse_arguments(ARG
711 "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH"
712 "ENTITLEMENTS"
713 "DEPENDS"
714 ${ARGN})
715
711716 llvm_process_sources( ALL_FILES ${ARG_UNPARSED_ARGUMENTS} )
712717
713718 list(APPEND LLVM_COMMON_DEPENDS ${ARG_DEPENDS})
786791 target_link_libraries(${name} PRIVATE ${LLVM_PTHREAD_LIB})
787792 endif()
788793
789 llvm_codesign(${name})
794 llvm_codesign(TARGET ${name} ENTITLEMENTS ${ARG_ENTITLEMENTS})
790795 endmacro(add_llvm_executable name)
791796
792797 function(export_executable_symbols target)
16251630 endif()
16261631 endfunction()
16271632
1628 function(llvm_codesign name)
1633 # Usage: llvm_codesign(TARGET name [ENTITLEMENTS file])
1634 #
1635 # Code-sign the given TARGET with the global LLVM_CODESIGNING_IDENTITY or skip
1636 # if undefined. Customize capabilities by passing a file path to ENTITLEMENTS.
1637 #
1638 function(llvm_codesign)
1639 cmake_parse_arguments(ARG "" "TARGET;ENTITLEMENTS" "" ${ARGN})
1640
16291641 if(NOT LLVM_CODESIGNING_IDENTITY)
16301642 return()
16311643 endif()
16411653 OUTPUT_VARIABLE CMAKE_CODESIGN_ALLOCATE
16421654 )
16431655 endif()
1656 if(DEFINED ARG_ENTITLEMENTS)
1657 set(PASS_ENTITLEMENTS --entitlements ${ARG_ENTITLEMENTS})
1658 endif()
1659
16441660 add_custom_command(
1645 TARGET ${name} POST_BUILD
1661 TARGET ${ARG_TARGET} POST_BUILD
16461662 COMMAND ${CMAKE_COMMAND} -E
16471663 env CODESIGN_ALLOCATE=${CMAKE_CODESIGN_ALLOCATE}
16481664 ${CMAKE_CODESIGN} -s ${LLVM_CODESIGNING_IDENTITY}
1649 $}>
1665 ${PASS_ENTITLEMENTS} $}>
16501666 )
16511667 endif()
16521668 endfunction()