diff --git a/.github/workflows/MacOS-pack.yml b/.github/workflows/MacOS-pack.yml new file mode 100644 index 00000000..7bda0e6b --- /dev/null +++ b/.github/workflows/MacOS-pack.yml @@ -0,0 +1,61 @@ +name: Packaging(MacOS) + +on: + push: + branches: + - master + - feature/RND-680-macos-.dmg-package-build + paths-ignore: + - 'README.md' + - 'LICENSE' + + pull_request: + paths-ignore: + - 'README.md' + - 'LICENSE' + +env: + PRODUCT: flameshot + +jobs: + catalina: + name: macOS Catalina 10.15 + runs-on: macos-10.15 + + steps: + - name: Checkout Source code + uses: actions/checkout@v1 + + - name: Install Qt + run: brew install qt cmake + + - name: Configure + run: | + mkdir build + cd build + rm -rf ./src/flameshot.dmg ./src/flameshot.app/ + cmake .. -DQt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5 + + - name: Compile + run: | + cd build + make + + - name: Build dmg image + run: | + cd build + /usr/local/opt/qt5/bin/macdeployqt src/flameshot.app -dmg + + - name: Upload dmg image + shell: bash + run: | + python3 -m pip install -U -q requests + echo "================MacOS dmg image download link================" + echo $(python3 $GITHUB_WORKSPACE/scripts/upload_services/transferwee.py upload $GITHUB_WORKSPACE/build/src/flameshot.dmg) + echo "=====no operation for you can see link in the log console=====" + + - name: Artifact Upload + uses: actions/upload-artifact@v2 + with: + name: MacOS-artifact + path: ${{ github.workspace }}/build/src/flameshot.dmg diff --git a/CMakeLists.txt b/CMakeLists.txt index fd4b1445..3f2274c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.13) # cmake_policy(SET CMP0076 OLD) # This can be read from ${PROJECT_NAME} after project() is called +if(APPLE) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version") +endif() + project( flameshot VERSION 0.8.5.4 @@ -18,6 +22,10 @@ if(WIN32) add_definitions(-DFLAMESHOT_VERSION_BUGFIX=${CMAKE_PROJECT_VERSION_PATCH}) add_definitions(-DFLAMESHOT_VERSION_BUILD=1) add_definitions(-DFLAMESHOT_VERSION_STRING="${PROJECT_VERSION}") +elseif(APPLE) + set(Qt5_DIR "$(brew --prefix qt5)/lib/cmake/Qt5/" CACHE PATH "directory where Qt5Config.cmake exists.") + set(CMAKE_MACOSX_BUNDLE ON) + set(CMAKE_MACOSX_RPATH ON) endif() set(RUN_IN_PLACE ${DEFAULT_RUN_IN_PLACE} CACHE BOOL "Run directly in source directory structure") diff --git a/cmake/modules/MacOSXBundleInfo.plist.in b/cmake/modules/MacOSXBundleInfo.plist.in new file mode 100644 index 00000000..bf1e2f76 --- /dev/null +++ b/cmake/modules/MacOSXBundleInfo.plist.in @@ -0,0 +1,40 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + flameshot + CFBundleGetInfoString + + CFBundleIconFile + flameshot + CFBundleIdentifier + https://flameshot.org/ + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + + CFBundleName + + CFBundlePackageType + APPL + CFBundleShortVersionString + + CFBundleSignature + ???? + CFBundleVersion + 0.8.5 + CSResourcesFileMapped + + NSHumanReadableCopyright + + LSMinimumSystemVersion + 10.15 + NSPrincipalClass + NSApplication + NSHighResolutionCapable + True + + diff --git a/data/img/app/org.flameshot.Flameshot-1024.png b/data/img/app/org.flameshot.Flameshot-1024.png new file mode 100644 index 00000000..e6f5d3c7 Binary files /dev/null and b/data/img/app/org.flameshot.Flameshot-1024.png differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eb37bcaa..3b55a49e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,7 +14,43 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) -add_executable(flameshot) +# set application icon +if (APPLE) + # generate iconset + execute_process( + COMMAND bash "-c" "mkdir -p flameshot.iconset" + ) + execute_process( + COMMAND bash "-c" "sips -z 16 16 ../data/img/app/flameshot.png --out flameshot.iconset/icon_16x16.png" + COMMAND bash "-c" "sips -z 32 32 ../data/img/app/flameshot.png --out flameshot.iconset/icon_16x16@2x.png" + COMMAND bash "-c" "sips -z 32 32 ../data/img/app/flameshot.png --out flameshot.iconset/icon_32x32.png" + COMMAND bash "-c" "sips -z 64 64 ../data/img/app/flameshot.png --out flameshot.iconset/icon_32x32@2x.png" + COMMAND bash "-c" "sips -z 64 64 ../data/img/app/flameshot.png --out flameshot.iconset/icon_64x64x.png" + COMMAND bash "-c" "sips -z 128 128 ../data/img/app/flameshot.png --out flameshot.iconset/icon_64x64@2.png" + COMMAND bash "-c" "sips -z 128 128 ../data/img/app/flameshot.png --out flameshot.iconset/icon_128x128.png" + COMMAND bash "-c" "sips -z 256 256 ../data/img/app/org.flameshot.Flameshot-1024.png --out flameshot.iconset/icon_128x128@2x.png" + COMMAND bash "-c" "sips -z 256 256 ../data/img/app/org.flameshot.Flameshot-1024.png --out flameshot.iconset/icon_256x256.png" + COMMAND bash "-c" "sips -z 512 512 ../data/img/app/org.flameshot.Flameshot-1024.png --out flameshot.iconset/icon_256x256@2x.png" + COMMAND bash "-c" "sips -z 512 512 ../data/img/app/org.flameshot.Flameshot-1024.png --out flameshot.iconset/icon_512x512.png" + COMMAND bash "-c" "sips -z 1024 1024 ../data/img/app/org.flameshot.Flameshot-1024.png --out flameshot.iconset/icon_512x512@2x.png" + COMMAND bash "-c" "iconutil -c icns flameshot.iconset" + ) + + execute_process( + COMMAND bash "-c" "rm -R flameshot.iconset" + ) + + # Set application icon + set(MACOSX_BUNDLE_ICON_FILE flameshot.icns) + + # And this part tells CMake where to find and install the file itself + set(APP_ICON_MACOSX ${CMAKE_BINARY_DIR}/flameshot.icns) + set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") + + add_executable(flameshot MACOSX_BUNDLE main.cpp ${APP_ICON_MACOSX}) +else() + add_executable(flameshot) +endif() add_executable(Flameshot::flameshot ALIAS flameshot) @@ -22,6 +58,7 @@ if(WIN32) set_property(TARGET flameshot PROPERTY WIN32_EXECUTABLE true) endif() + add_subdirectory(cli) add_subdirectory(config) add_subdirectory(core) @@ -154,10 +191,10 @@ include(GNUInstallDirs) set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/Flameshot) # Install binary -install( - TARGETS flameshot - EXPORT flameshot-targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS flameshot + EXPORT flameshot-targets + BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) # Install desktop files, completion and dbus files configure_file(${CMAKE_SOURCE_DIR}/data/desktopEntry/package/org.flameshot.Flameshot.desktop @@ -245,3 +282,21 @@ if(WIN32) message("Unable to find executable QTDIR/bin/windeployqt.") endif() endif() + +# macdeployqt +if (APPLE) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") + execute_process(COMMAND brew --prefix qt5 OUTPUT_VARIABLE QTDIR) + string(REGEX REPLACE "\n$" "" QTDIR "${QTDIR}") + set(MAC_DEPLOY_QT ${QTDIR}/bin/macdeployqt) + if (EXISTS ${MAC_DEPLOY_QT}) + set_source_files_properties(resources/icon.icns PROPERTIES + MACOSX_PACKAGE_LOCATION Resources) + + set_target_properties(${target} PROPERTIES + MACOSX_BUNDLE TRUE + ) + else () + message("Unable to find executable ${MAC_DEPLOY_QT}.") + endif () +endif ()