FLTK logo

[master] fcd5239 - CMake: Fix macOS bundle wrapper generation

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] fcd5239 - CMake: Fix macOS bundle wrapper generation "Albrecht Schlosser" Aug 18, 2020  
 
commit fcd5239adc468b58a130356be79e6e741689e6b0
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Tue Aug 18 16:23:25 2020 +0200
Commit:     Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Tue Aug 18 16:23:25 2020 +0200

    CMake: Fix macOS bundle wrapper generation
    
    Now bundle wrapper scripts are created in the particular build folder,
    i.e. in subdir 'Debug', 'Release' etc. in multi config builds (Xcode).
    To do this, the scripts are now copied whenever the target is built
    and not during the configuration phase.
    
    To do: "install" wrapper scripts.

 CMake/fl_create_example.cmake | 38 ++++++++++++++++++--------------------
 fluid/CMakeLists.txt          | 18 ++++++++++++++++--
 2 files changed, 34 insertions(+), 22 deletions(-)

diff --git CMake/fl_create_example.cmake CMake/fl_create_example.cmake
index 84f726d..9d63602 100644
--- CMake/fl_create_example.cmake
+++ CMake/fl_create_example.cmake
@@ -103,26 +103,6 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
   endif (MAC_BUNDLE AND ICON_NAME)
 
   ##############################################################################
-  # copy macOS "bundle wrapper" (shell script) to target (bin) directory
-  ##############################################################################
-  #  (1) file (COPY   ...) to set execution permissions
-  #  (2) file (RENAME ...) to move the file to its final place
-  ##############################################################################
-
-  if (MAC_BUNDLE)
-    file (COPY
-      ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/macOS-bundle-wrapper.in
-      DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
-      FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
-        GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
-    )
-    file (RENAME
-      ${CMAKE_CURRENT_BINARY_DIR}/macOS-bundle-wrapper.in
-      ${EXECUTABLE_OUTPUT_PATH}/${TARGET_NAME}
-    )
-  endif (MAC_BUNDLE)
-
-  ##############################################################################
   # add executable target and set properties (all platforms)
   ##############################################################################
 
@@ -139,6 +119,24 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
     set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/${PLIST}")
   endif (PLIST)
 
+  ##############################################################################
+  # Copy macOS "bundle wrapper" (shell script) to target directory.
+  # The "custom command" will be executed "POST_BUILD".
+  ##############################################################################
+
+  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 chmod u+x,g+x,o+x ${WRAPPER}
+      BYPRODUCTS ${WRAPPER}
+      # COMMENT "Creating macOS bundle wrapper script ${WRAPPER}"
+      VERBATIM
+    )
+    unset (WRAPPER)
+  endif (MAC_BUNDLE)
+
   ######################################################################
   # Parse optional fourth argument "ANDROID_OK", see description above.
   ######################################################################
diff --git fluid/CMakeLists.txt fluid/CMakeLists.txt
index 30b1058..cbe0435 100644
--- fluid/CMakeLists.txt
+++ fluid/CMakeLists.txt
@@ -49,9 +49,23 @@ endif (WIN32)
 if (APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL))
   set (ICON_NAME fluid.icns)
   set (ICON_PATH "${PROJECT_SOURCE_DIR}/fluid/fluid.app/Contents/Resources/${ICON_NAME}")
-  add_executable(fluid MACOSX_BUNDLE ${CPPFILES} ${ICON_PATH})
+  add_executable (fluid MACOSX_BUNDLE ${CPPFILES} ${ICON_PATH})
+
+  # create macOS bundle wrapper script
+
+  set (WRAPPER "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/fluid")
+  add_custom_command (
+    TARGET fluid POST_BUILD
+    COMMAND cp ${CMAKE_CURRENT_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}"
+    VERBATIM
+  )
+  unset (WRAPPER)
+
 else ()
-  add_executable(fluid WIN32 ${CPPFILES})
+  add_executable (fluid WIN32 ${CPPFILES})
 endif (APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL))
 
 target_link_libraries(fluid fltk fltk_images fltk_forms)
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.