chore: migrate to CMake

This commit is contained in:
Gary Wang 2019-11-23 20:51:58 +08:00
parent ebff682984
commit 3f91d8271b
3 changed files with 94 additions and 0 deletions

3
.gitignore vendored
View File

@ -3,3 +3,6 @@
# Translation files
*.qm
# Generic Build Dir
[Bb]uild/

79
CMakeLists.txt Normal file
View File

@ -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)

View File

@ -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