2019-11-23 20:51:58 +08:00
|
|
|
project (pineapple-pictures)
|
|
|
|
|
|
|
|
cmake_minimum_required (VERSION 3.9.5)
|
|
|
|
|
2020-11-15 20:28:05 +08:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
|
|
|
|
2019-11-23 20:51:58 +08:00
|
|
|
include (GNUInstallDirs)
|
2020-08-13 19:45:38 +08:00
|
|
|
include (FeatureSummary)
|
2019-11-23 20:51:58 +08:00
|
|
|
|
|
|
|
set (CMAKE_AUTOMOC ON)
|
|
|
|
set (CMAKE_AUTORCC ON)
|
2020-01-30 11:35:15 +08:00
|
|
|
set (QT_MINIMUM_VERSION "5.10")
|
2019-11-23 20:51:58 +08:00
|
|
|
|
2020-11-15 19:53:47 +08:00
|
|
|
option (EXIV2_METADATA_SUPPORT "Better image metadata support via libexiv2" ON)
|
|
|
|
|
2019-11-23 20:51:58 +08:00
|
|
|
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets Svg LinguistTools)
|
|
|
|
|
2020-11-15 19:53:47 +08:00
|
|
|
if (EXIV2_METADATA_SUPPORT)
|
2020-11-15 20:28:05 +08:00
|
|
|
find_package(LibExiv2)
|
|
|
|
set_package_properties(LibExiv2 PROPERTIES
|
2020-11-15 19:53:47 +08:00
|
|
|
URL "https://www.exiv2.org"
|
|
|
|
DESCRIPTION "image metadata support"
|
|
|
|
TYPE OPTIONAL
|
|
|
|
PURPOSE "Bring better image metadata support"
|
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
#LibExiv2_FOUND
|
2019-11-23 20:51:58 +08:00
|
|
|
set (PPIC_CPP_FILES
|
2020-11-05 14:12:58 +08:00
|
|
|
app/main.cpp
|
2020-12-29 23:28:17 +08:00
|
|
|
app/framelesswindow.cpp
|
2020-11-05 14:12:58 +08:00
|
|
|
app/mainwindow.cpp
|
2021-01-24 00:07:58 +08:00
|
|
|
app/actionmanager.cpp
|
2020-11-05 14:12:58 +08:00
|
|
|
app/graphicsview.cpp
|
|
|
|
app/graphicsscene.cpp
|
|
|
|
app/bottombuttongroup.cpp
|
|
|
|
app/navigatorview.cpp
|
|
|
|
app/opacityhelper.cpp
|
|
|
|
app/toolbutton.cpp
|
|
|
|
app/settings.cpp
|
|
|
|
app/settingsdialog.cpp
|
|
|
|
app/aboutdialog.cpp
|
|
|
|
app/metadatamodel.cpp
|
|
|
|
app/metadatadialog.cpp
|
2020-11-15 19:53:47 +08:00
|
|
|
app/exiv2wrapper.cpp
|
2021-02-09 14:19:09 +08:00
|
|
|
app/playlistmanager.cpp
|
2019-11-23 20:51:58 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
set (PPIC_HEADER_FILES
|
2020-12-29 23:28:17 +08:00
|
|
|
app/framelesswindow.h
|
2020-11-05 14:12:58 +08:00
|
|
|
app/mainwindow.h
|
2021-01-24 00:07:58 +08:00
|
|
|
app/actionmanager.h
|
2020-11-05 14:12:58 +08:00
|
|
|
app/graphicsview.h
|
|
|
|
app/graphicsscene.h
|
|
|
|
app/bottombuttongroup.h
|
|
|
|
app/navigatorview.h
|
|
|
|
app/opacityhelper.h
|
|
|
|
app/toolbutton.h
|
|
|
|
app/settings.h
|
|
|
|
app/settingsdialog.h
|
|
|
|
app/aboutdialog.h
|
|
|
|
app/metadatamodel.h
|
|
|
|
app/metadatadialog.h
|
2020-11-15 19:53:47 +08:00
|
|
|
app/exiv2wrapper.h
|
2021-02-09 14:19:09 +08:00
|
|
|
app/playlistmanager.h
|
2019-11-23 20:51:58 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
set (PPIC_QRC_FILES
|
2020-12-25 13:36:34 +08:00
|
|
|
assets/resources.qrc
|
2019-11-23 20:51:58 +08:00
|
|
|
)
|
|
|
|
|
2019-11-24 14:52:17 +08:00
|
|
|
set (PPIC_RC_FILES
|
|
|
|
# yeah, it's empty.
|
|
|
|
)
|
|
|
|
|
2019-11-23 20:51:58 +08:00
|
|
|
set (EXE_NAME ppic)
|
|
|
|
|
|
|
|
# Translation
|
2020-11-05 14:12:58 +08:00
|
|
|
file (GLOB PPIC_TS_FILES translations/*.ts)
|
2019-11-23 20:51:58 +08:00
|
|
|
set (PPIC_CPP_FILES_FOR_I18N ${PPIC_CPP_FILES})
|
|
|
|
|
|
|
|
qt5_create_translation(PPIC_QM_FILES ${PPIC_CPP_FILES_FOR_I18N} ${PPIC_TS_FILES})
|
|
|
|
|
2019-11-24 14:52:17 +08:00
|
|
|
if (WIN32)
|
2020-12-25 13:36:34 +08:00
|
|
|
list(APPEND PPIC_RC_FILES assets/pineapple-pictures.rc)
|
2019-11-24 14:52:17 +08:00
|
|
|
endif ()
|
|
|
|
|
2019-11-23 20:51:58 +08:00
|
|
|
add_executable (${EXE_NAME}
|
|
|
|
${PPIC_HEADER_FILES}
|
|
|
|
${PPIC_CPP_FILES}
|
|
|
|
${PPIC_QRC_FILES}
|
2019-11-24 14:52:17 +08:00
|
|
|
${PPIC_RC_FILES}
|
2019-11-23 20:51:58 +08:00
|
|
|
${PPIC_QM_FILES}
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries (${EXE_NAME} Qt5::Widgets Qt5::Svg)
|
|
|
|
|
2020-11-15 20:28:05 +08:00
|
|
|
if (LibExiv2_FOUND)
|
2020-11-15 19:53:47 +08:00
|
|
|
message(INFO ${LibExiv2_INCLUDE_DIRS})
|
|
|
|
target_include_directories(${EXE_NAME}
|
|
|
|
PRIVATE
|
|
|
|
${LibExiv2_INCLUDE_DIRS}
|
|
|
|
)
|
|
|
|
target_link_libraries (${EXE_NAME}
|
2020-11-15 20:28:05 +08:00
|
|
|
LibExiv2::LibExiv2
|
2020-11-15 19:53:47 +08:00
|
|
|
)
|
|
|
|
target_compile_definitions(${EXE_NAME} PRIVATE
|
|
|
|
HAVE_EXIV2_VERSION="${LibExiv2_VERSION}"
|
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
|
2019-11-24 23:31:45 +08:00
|
|
|
# Extra build settings
|
|
|
|
if (WIN32)
|
|
|
|
set_property (
|
|
|
|
TARGET ${EXE_NAME}
|
|
|
|
PROPERTY WIN32_EXECUTABLE true
|
|
|
|
)
|
2020-08-10 23:41:59 +08:00
|
|
|
|
|
|
|
target_compile_definitions(${EXE_NAME} PRIVATE
|
|
|
|
FLAG_PORTABLE_MODE_SUPPORT=1
|
|
|
|
)
|
2019-11-24 23:31:45 +08:00
|
|
|
endif ()
|
|
|
|
|
2020-08-13 19:45:38 +08:00
|
|
|
# Helper macros for parsing and setting project version from `git describe --long` result
|
|
|
|
macro (ppic_set_version_via_describe _describe_long)
|
|
|
|
string (
|
|
|
|
REGEX REPLACE
|
|
|
|
"^([0-9a-z.]*)-[0-9]+-g[0-9a-f]*$"
|
|
|
|
"\\1"
|
|
|
|
_tag_parts
|
|
|
|
"${_describe_long}"
|
|
|
|
)
|
|
|
|
list (GET _tag_parts 0 _matched_tag_version)
|
|
|
|
if ("${_matched_tag_version}" MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$")
|
|
|
|
string (
|
|
|
|
REGEX REPLACE
|
|
|
|
"^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$"
|
|
|
|
"\\1;\\2;\\3"
|
|
|
|
_ver_parts
|
|
|
|
"${_matched_tag_version}"
|
|
|
|
)
|
|
|
|
list (GET _ver_parts 0 CPACK_PACKAGE_VERSION_MAJOR)
|
|
|
|
list (GET _ver_parts 1 CPACK_PACKAGE_VERSION_MINOR)
|
|
|
|
list (GET _ver_parts 2 CPACK_PACKAGE_VERSION_PATCH)
|
|
|
|
endif ()
|
|
|
|
endmacro ()
|
|
|
|
|
|
|
|
# Version setup
|
|
|
|
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|
|
|
find_package(Git)
|
|
|
|
set_package_properties(Git PROPERTIES TYPE OPTIONAL PURPOSE "Determine exact build version.")
|
|
|
|
if (GIT_FOUND)
|
|
|
|
execute_process (
|
|
|
|
COMMAND ${GIT_EXECUTABLE} describe --tags --always --long
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE _git_describe_long
|
|
|
|
)
|
|
|
|
string (REGEX REPLACE "\n" "" _git_describe_long "${_git_describe_long}")
|
|
|
|
ppic_set_version_via_describe(${_git_describe_long})
|
2020-09-29 09:45:07 +08:00
|
|
|
target_compile_definitions(${EXE_NAME} PRIVATE
|
|
|
|
GIT_DESCRIBE_VERSION_STRING="${_git_describe_long}"
|
|
|
|
)
|
2020-08-13 19:45:38 +08:00
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
|
2020-01-03 23:01:12 +08:00
|
|
|
# Helper macros for install settings
|
|
|
|
macro (ppic_convert_to_relative_path _var)
|
|
|
|
# Make sure _var is a relative path
|
|
|
|
if (IS_ABSOLUTE "${${_var}}")
|
|
|
|
file (RELATIVE_PATH ${_var} "${CMAKE_INSTALL_PREFIX}" "${${_var}}")
|
|
|
|
endif ()
|
|
|
|
endmacro ()
|
|
|
|
|
2019-11-23 20:51:58 +08:00
|
|
|
# Install settings
|
2020-01-03 23:01:12 +08:00
|
|
|
if (WIN32)
|
|
|
|
# FIXME: try to avoid install to a "bin" subfolder under windows...
|
|
|
|
# when fixed, don't forget to update the CI config file...
|
|
|
|
set (BIN_INSTALL_DIR "") # seems useless, don't know why...
|
|
|
|
elseif (UNIX)
|
2019-11-23 20:51:58 +08:00
|
|
|
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
set(CMAKE_INSTALL_PREFIX /usr)
|
|
|
|
endif ()
|
|
|
|
|
2020-01-03 23:01:12 +08:00
|
|
|
set (BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}") # relative, usually "bin"
|
|
|
|
ppic_convert_to_relative_path(BIN_INSTALL_DIR)
|
|
|
|
set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") # "lib" or "lib64"
|
|
|
|
ppic_convert_to_relative_path(LIB_INSTALL_DIR)
|
2019-11-23 20:51:58 +08:00
|
|
|
|
|
|
|
# install icon
|
|
|
|
install (
|
2020-12-25 13:53:57 +08:00
|
|
|
FILES assets/icons/app-icon.svg
|
2019-11-23 20:51:58 +08:00
|
|
|
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps"
|
|
|
|
RENAME pineapple-pictures.svg
|
|
|
|
)
|
|
|
|
|
|
|
|
# install shortcut
|
|
|
|
install (
|
2020-09-15 12:03:03 +08:00
|
|
|
FILES dist/net.blumia.pineapple-pictures.desktop
|
2019-11-23 20:51:58 +08:00
|
|
|
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications"
|
|
|
|
)
|
2020-09-14 18:34:30 +08:00
|
|
|
|
|
|
|
# install app metadata file for appstream (and some other stuff using this metadata like snapcraft)
|
|
|
|
install (
|
|
|
|
FILES dist/appstream/net.blumia.pineapple-pictures.appdata.xml
|
|
|
|
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
|
|
|
|
)
|
2020-01-03 23:01:12 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set (INSTALL_TARGETS_DEFAULT_ARGS
|
|
|
|
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
|
|
|
|
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
|
|
|
|
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} COMPONENT Devel
|
|
|
|
)
|
2019-11-23 20:51:58 +08:00
|
|
|
|
2020-01-03 23:01:12 +08:00
|
|
|
install (
|
|
|
|
TARGETS ${EXE_NAME}
|
|
|
|
${INSTALL_TARGETS_DEFAULT_ARGS}
|
|
|
|
)
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
set (QM_FILE_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}/translations")
|
|
|
|
else ()
|
|
|
|
set (QM_FILE_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/pineapple-pictures/translations")
|
2020-01-05 14:30:33 +08:00
|
|
|
target_compile_definitions(${EXE_NAME}
|
|
|
|
PRIVATE QM_FILE_INSTALL_DIR=${QM_FILE_INSTALL_DIR}
|
|
|
|
)
|
2020-01-03 23:01:12 +08:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
install (
|
|
|
|
FILES ${PPIC_QM_FILES}
|
|
|
|
DESTINATION ${QM_FILE_INSTALL_DIR}
|
|
|
|
)
|
|
|
|
|
2020-11-15 19:53:47 +08:00
|
|
|
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
|
|
|
|
2020-01-03 23:01:12 +08:00
|
|
|
# CPACK: General Settings
|
|
|
|
set (CPACK_GENERATOR "TBZ2")
|
2020-04-20 10:57:27 +08:00
|
|
|
set (CPACK_PACKAGE_NAME "pineapple-pictures")
|
2020-01-03 23:01:12 +08:00
|
|
|
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Yet another image viewer")
|
|
|
|
set (CPACK_PACKAGE_VENDOR "Gary Wang")
|
2020-09-30 23:54:24 +08:00
|
|
|
set (CPACK_PACKAGE_CONTACT "https://github.com/BLumia/pineapple-pictures/issues/")
|
2020-01-03 23:01:12 +08:00
|
|
|
if (WIN32)
|
|
|
|
# ...
|
|
|
|
elseif (APPLE)
|
|
|
|
# ...
|
|
|
|
elseif (UNIX)
|
2020-04-20 10:57:27 +08:00
|
|
|
set (CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
|
2020-11-17 19:32:53 +08:00
|
|
|
set (CPACK_DEBIAN_PACKAGE_SHILIBDEPS ON)
|
2020-04-20 10:57:27 +08:00
|
|
|
set (CPACK_DEBIAN_PACKAGE_RECOMMENDS "kimageformat-plugins")
|
2020-01-03 23:01:12 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
include(CPack)
|