Skip to content

Commit

Permalink
Refactor CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
OrkunTokdemir committed Feb 22, 2023
1 parent 3ededae commit 1d521c8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 39 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/Linux-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ jobs:
mkdir -p ${APPIMAGE_DST_PATH}
cd $GITHUB_WORKSPACE
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr -DUSE_LAUNCHER_ABSOLUTE_PATH:BOOL=OFF
make -j$(nproc) DESTDIR=${APPIMAGE_DST_PATH} install
cmake -S -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr/${APPIMAGE_DST_PATH} -DUSE_LAUNCHER_ABSOLUTE_PATH:BOOL=OFF
cmake --build build --target install --config RelWithDebInfo -- -j$(nproc)
$GITHUB_WORKSPACE/appimagetool -s deploy ${APPIMAGE_DST_PATH}/usr/share/applications/org.flameshot.Flameshot.desktop
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/MacOS-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,12 @@ jobs:

- name: Configure
run: |
mkdir -p "${DIR_BULD}"
cd "${DIR_BULD}"
rm -rf ./src/flameshot.dmg ./src/flameshot.app/
cmake .. -DQt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5 -DUSE_MONOCHROME_ICON=True
rm -rf "${DIR_BULD}"/src/flameshot.dmg "${DIR_BULD}"/src/flameshot.app/
cmake -S . -B "${DIR_BULD}" -DQt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5 -DUSE_MONOCHROME_ICON=True
- name: Compile
run: |
cd "${DIR_BULD}"
make
cmake --build "${DIR_BULD}"
- name: Create key-chain and import certificate
run: |
Expand Down
10 changes: 4 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@ environment:
build_script:
- cmd: >-
mkdir build
cd build
set QTDIR=%Qt5_INSTALL_DIR%
set "VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC"
set "OPENSSL_ROOT_DIR=C:/OpenSSL-v111-Win64"
cmake c:\projects\source -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE:STRING=Release -DENABLE_OPENSSL=ON -DRUN_IN_PLACE=OFF
cmake -S c:\projects\source -B build -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE:STRING=Release -DENABLE_OPENSSL=ON -DRUN_IN_PLACE=OFF
cmake --build build --parallel 2 --config "Release"
cmake --build . --parallel 2 --config "Release"
cd build
cpack -G WIX -B package
Expand Down
44 changes: 19 additions & 25 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,36 @@ set(CMAKE_AUTOUIC ON)

# 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 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out flameshot.iconset/icon_16x16.png"
COMMAND bash "-c" "sips -z 32 32 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out flameshot.iconset/icon_16x16@2x.png"
COMMAND bash "-c" "sips -z 32 32 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out flameshot.iconset/icon_32x32.png"
COMMAND bash "-c" "sips -z 64 64 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out flameshot.iconset/icon_32x32@2x.png"
COMMAND bash "-c" "sips -z 64 64 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out flameshot.iconset/icon_64x64x.png"
COMMAND bash "-c" "sips -z 128 128 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out flameshot.iconset/icon_64x64@2.png"
COMMAND bash "-c" "sips -z 128 128 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out flameshot.iconset/icon_128x128.png"
COMMAND bash "-c" "sips -z 256 256 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out flameshot.iconset/icon_128x128@2x.png"
COMMAND bash "-c" "sips -z 256 256 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out flameshot.iconset/icon_256x256.png"
COMMAND bash "-c" "sips -z 512 512 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out flameshot.iconset/icon_256x256@2x.png"
COMMAND bash "-c" "sips -z 512 512 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out flameshot.iconset/icon_512x512.png"
COMMAND bash "-c" "sips -z 1024 1024 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out flameshot.iconset/icon_512x512@2x.png"


COMMAND bash "-c" "iconutil -c icns flameshot.iconset"
)
set(FLAMESHOT_ICONSET ${CMAKE_BINARY_DIR}/flameshot.iconset)
set(FLAMESHOT_ICNS ${CMAKE_BINARY_DIR}/flameshot.icns)

# generate iconset
execute_process(
COMMAND bash "-c" "rm -R flameshot.iconset"
COMMAND bash "-c" "mkdir -p \"${FLAMESHOT_ICONSET}\""
)

execute_process(
# copy icon from cache generated on the localhost if generation on CI failed
COMMAND bash "-c" "[[ -r 'flameshot.icns' ]] || cp \"${CMAKE_SOURCE_DIR}\"/packaging/macos/flameshot.icns ./"
COMMAND bash "-c" "sips -z 16 16 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out \"${FLAMESHOT_ICONSET}\"/icon_16x16.png"
COMMAND bash "-c" "sips -z 32 32 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out \"${FLAMESHOT_ICONSET}\"/icon_16x16@2x.png"
COMMAND bash "-c" "sips -z 32 32 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out \"${FLAMESHOT_ICONSET}\"/icon_32x32.png"
COMMAND bash "-c" "sips -z 64 64 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out \"${FLAMESHOT_ICONSET}\"/icon_32x32@2x.png"
COMMAND bash "-c" "sips -z 64 64 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out \"${FLAMESHOT_ICONSET}\"/icon_64x64x.png"
COMMAND bash "-c" "sips -z 128 128 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome.png --out \"${FLAMESHOT_ICONSET}\"/icon_64x64@2.png"
COMMAND bash "-c" "sips -z 128 128 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out \"${FLAMESHOT_ICONSET}\"/icon_128x128.png"
COMMAND bash "-c" "sips -z 256 256 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out \"${FLAMESHOT_ICONSET}\"/icon_128x128@2x.png"
COMMAND bash "-c" "sips -z 256 256 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out \"${FLAMESHOT_ICONSET}\"/icon_256x256.png"
COMMAND bash "-c" "sips -z 512 512 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out \"${FLAMESHOT_ICONSET}\"/icon_256x256@2x.png"
COMMAND bash "-c" "sips -z 512 512 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out \"${FLAMESHOT_ICONSET}\"/icon_512x512.png"
COMMAND bash "-c" "sips -z 1024 1024 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out \"${FLAMESHOT_ICONSET}\"/icon_512x512@2x.png"

COMMAND bash "-c" "iconutil -o \"${FLAMESHOT_ICNS}\" -c icns ${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(APP_ICON_MACOSX ${FLAMESHOT_ICNS})
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")

add_executable(flameshot MACOSX_BUNDLE main.cpp ${APP_ICON_MACOSX})
Expand Down

0 comments on commit 1d521c8

Please sign in to comment.