summaryrefslogtreecommitdiff
path: root/CMake/fl_create_example.cmake
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2021-05-13 16:16:50 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2021-05-13 16:18:13 +0200
commit773467dee4e79e0dfd97c5ee98fc253dead3302c (patch)
tree9ac93d67a1ed19257de461aa0089b4b521ed7c69 /CMake/fl_create_example.cmake
parent64296707d9e9b38dd9addf655f9b0943a4c54a54 (diff)
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
Diffstat (limited to 'CMake/fl_create_example.cmake')
-rw-r--r--CMake/fl_create_example.cmake29
1 files changed, 17 insertions, 12 deletions
diff --git a/CMake/fl_create_example.cmake b/CMake/fl_create_example.cmake
index 8071b5070..22c418bc6 100644
--- a/CMake/fl_create_example.cmake
+++ b/CMake/fl_create_example.cmake
@@ -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}"