From 3f91d8271b05ec6fdfe4b7835e70d0ce8d9277b7 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Sat, 23 Nov 2019 20:51:58 +0800 Subject: [PATCH] chore: migrate to CMake --- .gitignore | 3 ++ CMakeLists.txt | 79 ++++++++++++++++++++++++++++++++++++++ pineapple-pictures.desktop | 12 ++++++ 3 files changed, 94 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 pineapple-pictures.desktop diff --git a/.gitignore b/.gitignore index 936149c..5e50d85 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ # Translation files *.qm + +# Generic Build Dir +[Bb]uild/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..053d2a3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,79 @@ +project (pineapple-pictures) + +cmake_minimum_required (VERSION 3.9.5) + +include (GNUInstallDirs) + +set (CMAKE_AUTOMOC ON) +set (CMAKE_AUTORCC ON) +set (QT_MINIMUM_VERSION "5.7.1") + +find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets Svg LinguistTools) + +set (PPIC_CPP_FILES + main.cpp + mainwindow.cpp + graphicsview.cpp + graphicsscene.cpp + bottombuttongroup.cpp + navigatorview.cpp + opacityhelper.cpp + toolbutton.cpp +) + +set (PPIC_HEADER_FILES + mainwindow.h + graphicsview.h + graphicsscene.h + bottombuttongroup.h + navigatorview.h + opacityhelper.h + toolbutton.h +) + +set (PPIC_QRC_FILES + resources.qrc +) + +set (EXE_NAME ppic) + +# Translation +file (GLOB PPIC_TS_FILES languages/*.ts) +set (PPIC_CPP_FILES_FOR_I18N ${PPIC_CPP_FILES}) + +qt5_create_translation(PPIC_QM_FILES ${PPIC_CPP_FILES_FOR_I18N} ${PPIC_TS_FILES}) + +add_executable (${EXE_NAME} + ${PPIC_HEADER_FILES} + ${PPIC_CPP_FILES} + ${PPIC_QRC_FILES} + ${PPIC_QM_FILES} +) + +target_link_libraries (${EXE_NAME} Qt5::Widgets Qt5::Svg) + +# Install settings +if (UNIX) + if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX /usr) + endif () + + install ( + TARGETS ${EXE_NAME} + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) + + # install icon + install ( + FILES icons/app-icon.svg + DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps" + RENAME pineapple-pictures.svg + ) + + # install shortcut + install ( + FILES pineapple-pictures.desktop + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" + ) +endif (UNIX) + diff --git a/pineapple-pictures.desktop b/pineapple-pictures.desktop new file mode 100644 index 0000000..443be59 --- /dev/null +++ b/pineapple-pictures.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Categories=Graphics; +Comment=Pineapple Pictures Image Viewer. +Exec=ppic %F +GenericName=Pictures +Icon=pineapple-pictures +Keywords=Picture;Image;Viewer;Jpg;Jpeg;Png; +MimeType=image/bmp;image/bmp24;image/jpg;image/jpe;image/jpeg;image/jpeg24;image/jng;image/pcd;image/pcx;image/png;image/tif;image/tiff;image/tiff24;image/dds;image/gif;image/sgi;image/j2k;image/jp2;image/pct;image/wdp;image/arw;image/icb;image/dng;image/vda;image/vst;image/svg;image/ptif;image/mef;image/xbm;image/svg+xml; +Name=Pineapple Pictures +StartupNotify=false +Type=Application +Terminal=false