Refactor macOS bundle generation to avoid "quarantine"

macOS Big Sur 11.3 introduced a new "security feature" such that
app bundles created from existing bundle templates in downloaded
files (tar distibutions, expanded) could no longer be executed
without unsetting the "quarantine" attribute. This commit fixes
this by creating all bundles from scratch.

Known *workaround* for older tarballs and snapshots:

  $ xattr -d -r com.apple.quarantine xxx.app
This commit is contained in:
Albrecht Schlosser
2021-05-13 16:16:50 +02:00
parent 64296707d9
commit 773467dee4
21 changed files with 57 additions and 172 deletions
+17 -12
View File
@@ -27,7 +27,7 @@
# Sources can be:
# - .c/.cxx files, e.g. 'hello.cxx'
# - .fl (fluid) files, e.g. 'radio.fl'
# - .plist file (macOS), e.g. 'editor-Info.plist'
# - .plist file (macOS), e.g. 'editor.plist'
# - .icns file (macOS Icon), e.g. 'checkers.icns'
# - .rc file (Windows resource file, e.g. icon definition)
#
@@ -39,10 +39,11 @@
# all other file types are added to the target's source files.
#
# macOS specific .icns and .plist files are ignored on other platforms.
# These files must reside in the subdirectory 'mac-resources'.
#
# - LIBRARIES:
# List of libraries (CMake target names), separated by ';'. Needs
# quotes if more than one library is needed, e.g. "fltk_gl;fltk"
# quotes if more than one library is required, e.g. "fltk_gl;fltk"
#
# CREATE_EXAMPLE can have an optional fourth argument with a list of options
# - the option ANDROID_OK is set if CREATE_EXAMPLE creates code for Android
@@ -99,7 +100,7 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
# set macOS (icon) resource path if applicable
if (MAC_BUNDLE AND ICON_NAME)
set (ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.app/Contents/Resources/${ICON_NAME}")
set (ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/mac-resources/${ICON_NAME}")
endif (MAC_BUNDLE AND ICON_NAME)
##############################################################################
@@ -109,7 +110,7 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
if (MAC_BUNDLE)
add_executable (${TARGET_NAME} MACOSX_BUNDLE ${srcs} ${ICON_PATH})
else ()
add_executable (${TARGET_NAME} WIN32 ${srcs} ${ICON_PATH})
add_executable (${TARGET_NAME} WIN32 ${srcs})
endif (MAC_BUNDLE)
set_target_properties (${TARGET_NAME} PROPERTIES OUTPUT_NAME ${NAME})
@@ -123,16 +124,19 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
endif()
endif (FLTK_HAVE_CAIRO)
if (ICON_PATH)
set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
set_target_properties (${TARGET_NAME} PROPERTIES RESOURCE ${ICON_PATH})
endif (ICON_PATH)
if (MAC_BUNDLE)
if (PLIST)
set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST
"${CMAKE_CURRENT_SOURCE_DIR}/mac-resources/${PLIST}")
endif()
if (PLIST)
set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/${PLIST}")
elseif (MAC_BUNDLE)
set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "${TARGET_NAME}")
set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "org.fltk.${TARGET_NAME}")
if (ICON_NAME)
set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
set_target_properties (${TARGET_NAME} PROPERTIES RESOURCE ${ICON_PATH})
endif ()
endif ()
##############################################################################
@@ -142,9 +146,10 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
if (MAC_BUNDLE)
set (WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${TARGET_NAME}")
add_custom_command (
TARGET ${TARGET_NAME} POST_BUILD
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/macOS-bundle-wrapper.in ${WRAPPER}
COMMAND cp ${FLTK_SOURCE_DIR}/CMake/macOS-bundle-wrapper.in ${WRAPPER}
COMMAND chmod u+x,g+x,o+x ${WRAPPER}
BYPRODUCTS ${WRAPPER}
# COMMENT "Creating macOS bundle wrapper script ${WRAPPER}"