From a63435e64a9dae88fb5d2a19dfc9aa231ccef521 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Mon, 18 Nov 2024 18:13:12 -0500 Subject: [PATCH] build: use cmake to make the macOS bundle --- cmake/Packaging.cmake | 21 +------- deploy/dist/mac/bundle/Contents/Info.plist.in | 31 ------------ deploy/dist/mac/bundle/Contents/PkgInfo.in | 1 - deploy/dist/mac/dmgbuild/settings.py | 4 +- .../Background.tiff => dmg-background.tiff} | Bin .../Resources/Volume.icns => dmg-volume.icns} | Bin scripts/lib/mac.py | 6 +-- src/cmd/deskflowc/CMakeLists.txt | 2 +- src/cmd/deskflows/CMakeLists.txt | 2 +- src/gui/CMakeLists.txt | 46 ++++++++++++------ .../Resources => src/gui/src}/Deskflow.icns | Bin 11 files changed, 38 insertions(+), 75 deletions(-) delete mode 100644 deploy/dist/mac/bundle/Contents/Info.plist.in delete mode 100644 deploy/dist/mac/bundle/Contents/PkgInfo.in rename deploy/{dist/mac/bundle/Contents/Resources/Background.tiff => dmg-background.tiff} (100%) rename deploy/{dist/mac/bundle/Contents/Resources/Volume.icns => dmg-volume.icns} (100%) rename {deploy/dist/mac/bundle/Contents/Resources => src/gui/src}/Deskflow.icns (100%) diff --git a/cmake/Packaging.cmake b/cmake/Packaging.cmake index 86bd21f38..ec2d16c7c 100644 --- a/cmake/Packaging.cmake +++ b/cmake/Packaging.cmake @@ -29,7 +29,7 @@ macro(configure_packaging) if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") configure_windows_packaging() elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - configure_mac_packaging() + set(OS_STRING "macos-${CMAKE_SYSTEM_PROCESSOR}") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") configure_linux_packaging() elseif(${CMAKE_SYSTEM_NAME} MATCHES "|.*BSD") @@ -75,25 +75,6 @@ macro(configure_windows_packaging) endmacro() -# -# macOS app bundle -# -macro(configure_mac_packaging) - - set(CMAKE_INSTALL_RPATH - "@loader_path/../Libraries;@loader_path/../Frameworks") - set(DESKFLOW_BUNDLE_SOURCE_DIR - ${PROJECT_SOURCE_DIR}/deploy/dist/mac/bundle - CACHE PATH "Path to the macOS app bundle") - set(DESKFLOW_BUNDLE_DIR ${PROJECT_BINARY_DIR}/bundle/Deskflow.app) - set(DESKFLOW_BUNDLE_BINARY_DIR ${DESKFLOW_BUNDLE_DIR}/Contents/MacOS) - - configure_files(${DESKFLOW_BUNDLE_SOURCE_DIR} ${DESKFLOW_BUNDLE_DIR}) - - set(OS_STRING "macos-${CMAKE_SYSTEM_PROCESSOR}") - -endmacro() - # # Linux packages # diff --git a/deploy/dist/mac/bundle/Contents/Info.plist.in b/deploy/dist/mac/bundle/Contents/Info.plist.in deleted file mode 100644 index 463953591..000000000 --- a/deploy/dist/mac/bundle/Contents/Info.plist.in +++ /dev/null @@ -1,31 +0,0 @@ - - - - CFBundleDevelopmentRegion - English - CFBundleDisplayName - Deskflow - CFBundleExecutable - deskflow - CFBundleIconFile - Deskflow.icns - CFBundleIdentifier - org.deskflow.deskflow - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - Deskflow - CFBundlePackageType - APPL - CFBundleSignature - DFLW - CFBundleShortVersionString - @DESKFLOW_VERSION@ - CFBundleVersion - @DESKFLOW_VERSION@ - NSHumanReadableCopyright - © 2024 Deskflow Developers - LSMinimumSystemVersion - 10.9.0 - - diff --git a/deploy/dist/mac/bundle/Contents/PkgInfo.in b/deploy/dist/mac/bundle/Contents/PkgInfo.in deleted file mode 100644 index b13f9472f..000000000 --- a/deploy/dist/mac/bundle/Contents/PkgInfo.in +++ /dev/null @@ -1 +0,0 @@ -APPLDFLW diff --git a/deploy/dist/mac/dmgbuild/settings.py b/deploy/dist/mac/dmgbuild/settings.py index 16ff4b8ad..ee740ae0c 100644 --- a/deploy/dist/mac/dmgbuild/settings.py +++ b/deploy/dist/mac/dmgbuild/settings.py @@ -12,12 +12,12 @@ format = defines.get("format", "UDBZ") size = defines.get("size", None) files = [app] symlinks = {"Applications": "/Applications"} -icon = os.path.join(app, "Contents/Resources/Volume.icns") +icon = os.path.join(app, "Contents/Resources/dmg-volume.icns") icon_locations = { app_basename: (144, 190), "Applications": (455, 190), } -background = os.path.join(app, "Contents/Resources/Background.tiff") +background = os.path.join(app, "Contents/Resources/dmg-background.tiff") show_status_bar = False show_tab_view = False show_toolbar = False diff --git a/deploy/dist/mac/bundle/Contents/Resources/Background.tiff b/deploy/dmg-background.tiff similarity index 100% rename from deploy/dist/mac/bundle/Contents/Resources/Background.tiff rename to deploy/dmg-background.tiff diff --git a/deploy/dist/mac/bundle/Contents/Resources/Volume.icns b/deploy/dmg-volume.icns similarity index 100% rename from deploy/dist/mac/bundle/Contents/Resources/Volume.icns rename to deploy/dmg-volume.icns diff --git a/scripts/lib/mac.py b/scripts/lib/mac.py index 81ef8545f..7707ac382 100644 --- a/scripts/lib/mac.py +++ b/scripts/lib/mac.py @@ -78,7 +78,7 @@ def package(filename_base, source_dir, build_dir, dist_dir, product_name): ) bundle_source_dir = os.path.join( - build_dir, os.path.join("bundle", product_name + ".app") + build_dir, os.path.join("bin", product_name + ".app") ) build_bundle(bundle_source_dir) @@ -139,8 +139,8 @@ def build_bundle(bundle_source_dir): print("Building bundle...") - # cmake build install target should run macdeployqt - cmd_utils.run("cmake --build build --target install", shell=True, print_cmd=True) + # cmake build target should run macdeployqt + cmd_utils.run("cmake --build build ", shell=True, print_cmd=True) def sign_bundle(bundle_source_dir, codesign_id): diff --git a/src/cmd/deskflowc/CMakeLists.txt b/src/cmd/deskflowc/CMakeLists.txt index 13873f3bd..eb167dd62 100644 --- a/src/cmd/deskflowc/CMakeLists.txt +++ b/src/cmd/deskflowc/CMakeLists.txt @@ -60,7 +60,7 @@ target_link_libraries( ${libs}) if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - install(TARGETS ${target} DESTINATION ${DESKFLOW_BUNDLE_BINARY_DIR}) + set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY $/MacOS) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") install(TARGETS ${target} DESTINATION bin) endif() diff --git a/src/cmd/deskflows/CMakeLists.txt b/src/cmd/deskflows/CMakeLists.txt index 1350787b0..8f1865b71 100644 --- a/src/cmd/deskflows/CMakeLists.txt +++ b/src/cmd/deskflows/CMakeLists.txt @@ -60,7 +60,7 @@ target_link_libraries( ${libs}) if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - install(TARGETS ${target} DESTINATION ${DESKFLOW_BUNDLE_BINARY_DIR}) + set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY $/MacOS) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") install(TARGETS ${target} DESTINATION bin) endif() diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 3c9009066..c9e11412f 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -13,7 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -set(target deskflow) +if(APPLE) + set(target Deskflow) +else() + set(target deskflow) +endif() set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) @@ -33,7 +37,11 @@ file( file(GLOB ui_files src/*.ui src/dialogs/*.ui) if(WIN32) - set(rc_files src/deskflow.rc ${PROJECT_BINARY_DIR}/src/version.rc) + set(platform_extra src/deskflow.rc ${PROJECT_BINARY_DIR}/src/version.rc) +elseif(APPLE) + set(platform_extra src/Deskflow.icns + ${PROJECT_SOURCE_DIR}/deploy/dmg-volume.icns ${PROJECT_SOURCE_DIR}/deploy/dmg-background.tiff) + set_source_files_properties(${platform_extra} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") endif() # regular exe headers @@ -46,7 +54,7 @@ include_directories(${PROJECT_BINARY_DIR}/src/lib/gui/gui_autogen/include) # generated includes include_directories(${PROJECT_BINARY_DIR}/config) -add_executable(${target} WIN32 ${sources} ${ui_files} ${rc_files}) +add_executable(${target} WIN32 MACOSX_BUNDLE ${sources} ${ui_files} ${platform_extra}) target_link_libraries( ${target} @@ -63,21 +71,27 @@ target_compile_definitions(${target} if(WIN32) set_target_properties(${target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT") +elseif(APPLE) + set_target_properties(${target} PROPERTIES + MACOSX_BUNDLE_BUNDLE_NAME "Deskflow" + MACOSX_BUNDLE_DISPLAY_NAME "Deskflow" + MACOSX_BUNDLE_GUI_IDENTIFIER "org.deskflow.deskflow" + MACOSX_BUNDLE_ICON_FILE Deskflow.icns + MACOSX_BUNDLE_INFO_STRING "${CMAKE_PROJECT_DESCRIPTION}" + MACOSX_BUNDLE_COPYRIGHT "© 2024 Deskflow Developers" + MACOSX_BUNDLE_BUNDLE_VERSION ${DESKFLOW_VERSION} + MACOSX_BUNDLE_LONG_VERSION_STRING ${DESKFLOW_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${DESKFLOW_VERSION} + ) + find_program(MACDEPLOYQT_BIN macdeployqt6) + add_custom_command( + TARGET ${target} POST_BUILD + COMMAND ${MACDEPLOYQT_BIN} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}.app" + ) + install(TARGETS ${target} BUNDLE DESTINATION .) endif() -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - - find_program(MACDEPLOYQT_BIN macdeployqt6) - message(STATUS "Found macdeployqt6: ${MACDEPLOYQT_BIN}") - - set(MACDEPLOYQT_CMD - "${MACDEPLOYQT_BIN} ${DESKFLOW_BUNDLE_DIR} -always-overwrite") - - install(TARGETS ${target} DESTINATION ${DESKFLOW_BUNDLE_BINARY_DIR}) - install(CODE "MESSAGE (\"Running: ${MACDEPLOYQT_CMD}\")") - install(CODE "execute_process(COMMAND ${MACDEPLOYQT_CMD})") - -elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") install(TARGETS ${target} DESTINATION bin) diff --git a/deploy/dist/mac/bundle/Contents/Resources/Deskflow.icns b/src/gui/src/Deskflow.icns similarity index 100% rename from deploy/dist/mac/bundle/Contents/Resources/Deskflow.icns rename to src/gui/src/Deskflow.icns