From 8c6ac1a21d50cf38be1a796d395998dc79a22385 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 17:32:46 +0800 Subject: [PATCH] add icns to macos bundle; use macdeployqt post build --- CMakeLists.txt | 18 ++++++++---------- resources/CMakeLists.txt | 23 +++++++++++++++++++---- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b2ca7b..8632b38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,15 +25,6 @@ endif() add_executable(squawk ${WIN32_FLAG} ${MACOSX_BUNDLE_FLAG}) target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}) -if (CMAKE_BUILD_TYPE STREQUAL "Release") - if (APPLE) - set_target_properties(squawk PROPERTIES - MACOSX_BUNDLE_EXECUTABLE_NAME "Squawk" - MACOSX_BUNDLE_ICON_FILE "${MACOSX_BUNDLE_ICON_FILE}" # TODO - MACOSX_BUNDLE_BUNDLE_NAME "Squawk" - MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in) - endif(APPLE) -endif() option(SYSTEM_QXMPP "Use system qxmpp lib" ON) option(WITH_KWALLET "Build KWallet support module" ON) @@ -142,4 +133,11 @@ add_subdirectory(ui) # Install the executable install(TARGETS squawk DESTINATION ${CMAKE_INSTALL_BINDIR}) -target_sources(squawk PRIVATE ${SQUAWK_WIN_RC} ${APP_ICON_MACOSX}) +if (CMAKE_BUILD_TYPE STREQUAL "Release") + if (APPLE) + add_custom_command(TARGET squawk POST_BUILD COMMENT "Running macdeployqt..." + COMMAND "${Qt5Widgets_DIR}/../../../bin/macdeployqt" "${CMAKE_CURRENT_BINARY_DIR}/squawk.app" + ) + endif(APPLE) +endif() + diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 42cb360..9288650 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -15,7 +15,9 @@ execute_process(COMMAND ${CONVERT_BIN} -background none -size 256x256 squawk.svg if (WIN32) execute_process(COMMAND ${CONVERT_BIN} squawk48.png squawk64.png squawk256.png squawk.ico WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set(SQUAWK_WIN_RC "${CMAKE_CURRENT_BINARY_DIR}/squawk.rc" PARENT_SCOPE) + set(SQUAWK_WIN_RC "${CMAKE_CURRENT_BINARY_DIR}/squawk.rc") + set(SQUAWK_WIN_RC "${SQUAWK_WIN_RC}" PARENT_SCOPE) + target_sources(squawk PRIVATE ${SQUAWK_WIN_RC}) endif(WIN32) if (APPLE) @@ -31,10 +33,22 @@ if (APPLE) execute_process(COMMAND convert -background none -resize !512x512 squawk.svg "icns.iconset/icon_512x512.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -resize !1024x1024 squawk.svg "icns.iconset/icon_512x512@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND iconutil -c icns "icns.iconset" -o "squawk.icns" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set(MACOSX_BUNDLE_ICON_FILE squawk.icns PARENT_SCOPE) - set(APP_ICON_MACOSX ${CMAKE_CURRENT_BINARY_DIR}/squawk.icns PARENT_SCOPE) - set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES + set(MACOSX_BUNDLE_ICON_FILE squawk.icns) + set(MACOSX_BUNDLE_ICON_FILE ${MACOSX_BUNDLE_ICON_FILE} PARENT_SCOPE) + set(APP_ICON_MACOSX ${CMAKE_CURRENT_BINARY_DIR}/squawk.icns) + set(APP_ICON_MACOSX ${APP_ICON_MACOSX} PARENT_SCOPE) + target_sources(squawk PRIVATE ${APP_ICON_MACOSX}) + set_source_files_properties(${APP_ICON_MACOSX} TARGET_DIRECTORY squawk PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") + if (CMAKE_BUILD_TYPE STREQUAL "Release") + if (APPLE) + set_target_properties(squawk PROPERTIES + MACOSX_BUNDLE_EXECUTABLE_NAME "Squawk" + MACOSX_BUNDLE_ICON_FILE "${MACOSX_BUNDLE_ICON_FILE}" # TODO + MACOSX_BUNDLE_BUNDLE_NAME "Squawk" + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in) + endif(APPLE) + endif() endif (APPLE) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps) @@ -42,3 +56,4 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk48.png DESTINATION ${CMAKE_INSTA install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk64.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/64x64/apps RENAME squawk.png) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk128.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps RENAME squawk.png) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk256.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/256x256/apps RENAME squawk.png) +