2025-02-26 20:58:16 +08:00
# SPDX-FileCopyrightText: 2022 - 2025 Gary Wang <git@blumia.net>
2022-06-19 16:17:38 +08:00
#
# SPDX-License-Identifier: MIT
2024-12-01 00:02:29 +08:00
cmake_minimum_required ( VERSION 3.16 )
2019-11-23 20:51:58 +08:00
2026-09-28 14:38:57 +08:00
project ( sarasacw-picture VERSION 1.6.0 ) # don't forget to update NEWS file and AppStream metadata.
2024-04-05 00:09:49 +08:00
2025-02-26 20:58:16 +08:00
include ( GNUInstallDirs )
include ( FeatureSummary )
2019-11-23 20:51:58 +08:00
2023-02-19 01:04:58 +08:00
option ( EXIV2_METADATA_SUPPORT "Better image metadata support via libexiv2" ON )
2024-12-24 22:37:16 +08:00
option ( TRANSLATION_RESOURCE_EMBEDDING "Embedding .qm translation files inside resource" OFF )
2023-02-19 01:04:58 +08:00
2023-11-25 02:18:37 +08:00
set ( CMAKE_CXX_STANDARD 17 )
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
2019-11-23 20:51:58 +08:00
set ( CMAKE_AUTOMOC ON )
set ( CMAKE_AUTORCC ON )
2026-07-04 22:17:40 +08:00
set ( CMAKE_AUTOUIC ON )
2019-11-23 20:51:58 +08:00
2025-05-23 00:06:43 +08:00
find_package ( QT NAMES Qt6 REQUIRED COMPONENTS Core )
2020-11-15 19:53:47 +08:00
2026-07-08 20:15:22 +08:00
set ( QT_MINIMUM_VERSION "6.5" )
2023-02-19 01:04:58 +08:00
find_package ( Qt ${ QT_VERSION_MAJOR } ${ QT_MINIMUM_VERSION } REQUIRED
2025-05-23 00:06:43 +08:00
COMPONENTS Widgets Svg SvgWidgets LinguistTools
2022-10-29 23:35:30 +08:00
OPTIONAL_COMPONENTS DBus
)
2019-11-23 20:51:58 +08:00
2020-11-15 19:53:47 +08:00
if ( EXIV2_METADATA_SUPPORT )
2025-02-20 08:13:16 +01:00
find_package ( exiv2 )
set_package_properties ( exiv2 PROPERTIES
2020-11-15 19:53:47 +08:00
URL "https://www.exiv2.org"
DESCRIPTION "image metadata support"
2025-02-26 20:58:16 +08:00
TYPE RECOMMENDED
2020-11-15 19:53:47 +08:00
PURPOSE "Bring better image metadata support"
)
endif ()
2026-09-28 14:38:57 +08:00
set ( SCWPIC_CPP_FILES
2020-11-05 14:12:58 +08:00
app/main.cpp
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/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
2024-12-31 10:57:21 +08:00
app/fileopeneventhandler.cpp
2026-07-25 12:06:11 +08:00
app/playlistscout.cpp
app/playlistscouts/qtscout.cpp
app/playlistscouts/explorerscout.cpp
2019-11-23 20:51:58 +08:00
)
2026-09-28 14:38:57 +08:00
set ( SCWPIC_HEADER_FILES
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/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
2024-12-31 10:57:21 +08:00
app/fileopeneventhandler.h
2026-07-25 12:06:11 +08:00
app/playlistscout.h
app/playlistscouts/qtscout.h
app/playlistscouts/explorerscout.h
2019-11-23 20:51:58 +08:00
)
2026-09-28 14:38:57 +08:00
set ( SCWPIC_UI_FILES
2026-07-04 22:17:40 +08:00
app/settingsdialog.ui
2026-07-07 12:16:36 +08:00
app/aboutdialog.ui
app/metadatadialog.ui
2026-07-24 14:57:41 +08:00
app/mainwindow.ui
2026-07-04 22:17:40 +08:00
)
2026-09-28 14:38:57 +08:00
set ( SCWPIC_QRC_FILES
2020-12-25 13:36:34 +08:00
assets/resources.qrc
2019-11-23 20:51:58 +08:00
)
2026-09-28 14:38:57 +08:00
set ( SCWPIC_RC_FILES
2019-11-24 14:52:17 +08:00
# yeah, it's empty.
)
2026-09-28 14:38:57 +08:00
set ( EXE_NAME scwpic )
2019-11-23 20:51:58 +08:00
# Translation
2026-09-28 14:38:57 +08:00
file ( GLOB SCWPIC_TS_FILES locales/app/*.ts )
set ( SCWPIC_CPP_FILES_FOR_I18N ${ SCWPIC_CPP_FILES } )
2019-11-23 20:51:58 +08:00
2026-10-09 20:09:04 +08:00
find_program ( METAGLOT_EXECUTABLE metaglot )
if ( NOT METAGLOT_EXECUTABLE )
message ( FATAL_ERROR "metaglot is required to render the localized metadata, install it from https://github.com/SarasasChipWorkshop/metaglot" )
2026-09-22 13:53:16 +08:00
endif ()
2019-11-24 14:52:17 +08:00
if ( WIN32 )
2026-09-25 17:13:27 +08:00
# Setup Windows RC files
2026-09-28 14:38:57 +08:00
set ( SCWPIC_RC_TEMPLATE_FILE ${ CMAKE_CURRENT_BINARY_DIR } /sarasacw-picture.rc.in )
2026-09-22 13:53:16 +08:00
execute_process (
2026-10-09 20:09:04 +08:00
COMMAND ${ METAGLOT_EXECUTABLE } render rc
2026-09-28 14:38:57 +08:00
--manifest ${ CMAKE_SOURCE_DIR } /dist/sarasacw-picture.rc.in.toml
2026-09-22 13:53:16 +08:00
--po ${ CMAKE_SOURCE_DIR } /locales/winrc/*.po
2026-09-28 14:38:57 +08:00
--template ${ CMAKE_SOURCE_DIR } /dist/sarasacw-picture.rc.in.liquid
--output ${ SCWPIC_RC_TEMPLATE_FILE }
2026-09-22 13:53:16 +08:00
RESULT_VARIABLE METAGLOT_RESULT
)
if ( NOT METAGLOT_RESULT EQUAL 0 )
2026-09-22 17:15:49 +08:00
message ( FATAL_ERROR "Failed to generate Windows RC file template via MetaGlot (exit code: ${METAGLOT_RESULT})." )
2026-09-22 13:53:16 +08:00
endif ()
2026-09-28 14:38:57 +08:00
configure_file ( ${ SCWPIC_RC_TEMPLATE_FILE } ${ CMAKE_CURRENT_BINARY_DIR } /sarasacw-picture.rc @ONLY )
list ( APPEND SCWPIC_RC_FILES ${ CMAKE_CURRENT_BINARY_DIR } /sarasacw-picture.rc )
2019-11-24 14:52:17 +08:00
endif ()
2024-12-02 00:25:48 +08:00
add_executable ( ${ EXE_NAME }
2026-09-28 14:38:57 +08:00
${ SCWPIC_HEADER_FILES }
${ SCWPIC_CPP_FILES }
${ SCWPIC_UI_FILES }
${ SCWPIC_QRC_FILES }
${ SCWPIC_RC_FILES }
2019-11-23 20:51:58 +08:00
)
2025-05-23 00:06:43 +08:00
set ( ADD_TRANSLATIONS_ADDITIONAL_ARGS )
2025-04-26 17:02:24 +08:00
2025-05-23 00:06:43 +08:00
if ( Qt6_VERSION VERSION_GREATER_EQUAL "6.9.0" )
set ( ADD_TRANSLATIONS_ADDITIONAL_ARGS MERGE_QT_TRANSLATIONS )
endif ()
2025-04-26 17:02:24 +08:00
2025-05-23 00:06:43 +08:00
if ( TRANSLATION_RESOURCE_EMBEDDING )
2026-09-28 14:38:57 +08:00
qt_add_translations ( ${ EXE_NAME } ${ ADD_TRANSLATIONS_ADDITIONAL_ARGS } TS_FILES ${ SCWPIC_TS_FILES } )
2024-04-20 16:40:07 +08:00
else ()
2026-09-28 14:38:57 +08:00
qt_add_translations ( ${ EXE_NAME } ${ ADD_TRANSLATIONS_ADDITIONAL_ARGS } TS_FILES ${ SCWPIC_TS_FILES } QM_FILES_OUTPUT_VARIABLE SCWPIC_QM_FILES )
2024-04-20 16:40:07 +08:00
endif ()
2024-04-05 00:09:49 +08:00
2026-09-28 10:40:14 +08:00
# YYC MARK:
# We use this to disable that Qt UIC generate code like `QMetaObject::connectSlotsByName(foobar);`
# for the header file of `.ui` file, which cause this application outputs log at runtime like
# `qt.core.qmetaobject.connectslotsbyname: QMetaObject::connectSlotsByName: No matching signal for on_actionXxx_triggered()`,
# because we only use UIC for building user interface and all signals and actions are managed by ourselves.
set_target_properties ( ${ EXE_NAME } PROPERTIES AUTOUIC_OPTIONS "-a" )
2026-07-24 14:57:41 +08:00
# YYC MARK:
# This is essential, otherwise Qt UIC generated UI header file
# can not find our header files if there are custom widgets inside UI file.
target_include_directories ( ${ EXE_NAME } PRIVATE app/ )
2026-09-28 14:38:57 +08:00
target_sources ( ${ EXE_NAME } PRIVATE ${ SCWPIC_QM_FILES } )
2024-04-05 00:09:49 +08:00
2025-05-23 00:06:43 +08:00
target_link_libraries ( ${ EXE_NAME } Qt ${ QT_VERSION_MAJOR } ::Widgets Qt ${ QT_VERSION_MAJOR } ::Svg Qt ${ QT_VERSION_MAJOR } ::SvgWidgets )
2019-11-23 20:51:58 +08:00
2025-02-20 08:13:16 +01:00
if ( exiv2_FOUND )
2025-05-24 23:19:26 +08:00
if ( NOT TARGET Exiv2::exiv2lib AND TARGET exiv2lib )
# for exiv2 0.27.x and (macOS?) conan build
add_library ( Exiv2::exiv2lib ALIAS exiv2lib )
endif ()
2020-11-15 19:53:47 +08:00
target_link_libraries ( ${ EXE_NAME }
2024-07-06 17:24:42 +08:00
Exiv2::exiv2lib
2020-11-15 19:53:47 +08:00
)
target_compile_definitions ( ${ EXE_NAME } PRIVATE
2025-02-20 08:13:16 +01:00
HAVE_EXIV2_VERSION= "${exiv2_VERSION}"
2020-11-15 19:53:47 +08:00
)
endif ()
2025-05-23 00:06:43 +08:00
if ( TARGET Qt6::DBus )
2022-10-29 23:35:30 +08:00
target_link_libraries ( ${ EXE_NAME }
2023-05-21 00:36:24 +08:00
Qt ${ QT_VERSION_MAJOR } ::DBus
2022-10-29 23:35:30 +08:00
)
target_compile_definitions ( ${ EXE_NAME } PRIVATE
HAVE_QTDBUS
)
endif ()
2019-11-24 23:31:45 +08:00
# Extra build settings
if ( WIN32 )
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
2026-09-28 14:38:57 +08:00
macro ( scwpic_set_version_via_describe _describe_long )
2020-08-13 19:45:38 +08:00
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
2026-09-28 14:38:57 +08:00
target_compile_definitions ( ${ EXE_NAME } PRIVATE SCWPIC_VERSION_STRING= "${CMAKE_PROJECT_VERSION}" )
2020-08-13 19:45:38 +08:00
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}" )
2026-09-28 14:38:57 +08:00
scwpic_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 ()
2019-11-23 20:51:58 +08:00
# Install settings
2020-01-03 23:01:12 +08:00
if ( WIN32 )
2024-12-02 00:25:48 +08:00
set_target_properties ( ${ EXE_NAME } PROPERTIES
WIN32_EXECUTABLE TRUE
)
2026-09-25 17:13:27 +08:00
# Setup Inno Setup script file
2026-10-13 10:31:02 +08:00
set ( INNO_SETUP_VERSION "7" CACHE STRING "Major version of Inno Setup that packages the installer; decides which language files count as official in the metaglot inno rendering." )
set_property ( CACHE INNO_SETUP_VERSION PROPERTY STRINGS 6 7 )
2026-09-28 14:38:57 +08:00
set ( SCWPIC_INNO_OUTPUT_DIR ${ CMAKE_CURRENT_BINARY_DIR } /inno-metadata )
2026-09-25 17:13:27 +08:00
execute_process (
2026-10-09 20:09:04 +08:00
COMMAND ${ METAGLOT_EXECUTABLE } render inno
2026-10-13 10:31:02 +08:00
--inno-version ${ INNO_SETUP_VERSION }
2026-09-28 14:38:57 +08:00
--manifest ${ CMAKE_SOURCE_DIR } /dist/scwpic.iss.in.toml
2026-09-25 17:13:27 +08:00
--po ${ CMAKE_SOURCE_DIR } /locales/inno/*.po
2026-09-28 14:38:57 +08:00
--iss-template ${ CMAKE_SOURCE_DIR } /dist/scwpic.iss.in.liquid
--isl-template ${ CMAKE_SOURCE_DIR } /dist/scwpic.isl.liquid
--iss-path scwpic.iss.in
2026-10-09 19:50:58 +08:00
--isl-path "Strings/{{ lang | default: name }}.isl"
2026-09-28 14:38:57 +08:00
--output ${ SCWPIC_INNO_OUTPUT_DIR }
2026-09-25 17:13:27 +08:00
RESULT_VARIABLE METAGLOT_INNO_RESULT
)
if ( NOT METAGLOT_INNO_RESULT EQUAL 0 )
message ( FATAL_ERROR "Failed to render Inno Setup script via MetaGlot (exit code: ${METAGLOT_INNO_RESULT})." )
endif ()
2026-09-28 14:38:57 +08:00
configure_file ( ${ SCWPIC_INNO_OUTPUT_DIR } /scwpic.iss.in ${ SCWPIC_INNO_OUTPUT_DIR } /scwpic.iss @ONLY )
2026-09-29 11:03:10 +08:00
2026-10-16 10:40:41 +08:00
# Setup MSIX metadata.
2026-09-29 11:03:10 +08:00
set ( SCWPIC_MSIX_OUTPUT_DIR ${ CMAKE_CURRENT_BINARY_DIR } /msix-metadata )
execute_process (
2026-10-09 20:09:04 +08:00
COMMAND ${ METAGLOT_EXECUTABLE } render msix
2026-09-29 11:03:10 +08:00
--manifest ${ CMAKE_SOURCE_DIR } /dist/AppxManifest.xml.in.toml
--po ${ CMAKE_SOURCE_DIR } /locales/msix/*.po
--manifest-template ${ CMAKE_SOURCE_DIR } /dist/AppxManifest.xml.in.liquid
--resources-template ${ CMAKE_SOURCE_DIR } /dist/Resources.resjson.liquid
--manifest-path AppxManifest.xml.in
--resources-path "Strings/{{ lang }}/Resources.resjson"
--output ${ SCWPIC_MSIX_OUTPUT_DIR }
RESULT_VARIABLE METAGLOT_MSIX_RESULT
)
if ( NOT METAGLOT_MSIX_RESULT EQUAL 0 )
message ( FATAL_ERROR "Failed to render MSIX metadata via MetaGlot (exit code: ${METAGLOT_MSIX_RESULT})." )
endif ()
configure_file ( ${ SCWPIC_MSIX_OUTPUT_DIR } /AppxManifest.xml.in ${ SCWPIC_MSIX_OUTPUT_DIR } /AppxManifest.xml @ONLY )
2024-12-02 00:25:48 +08:00
elseif ( APPLE )
2026-09-24 16:05:20 +08:00
# Include icon to project
2026-10-11 10:57:09 +08:00
set_source_files_properties ( dist/macos-icons/sarasacw-picture.icns PROPERTIES
2024-12-02 00:25:48 +08:00
MACOSX_PACKAGE_LOCATION "Resources"
)
2026-10-11 10:57:09 +08:00
target_sources ( ${ EXE_NAME } PRIVATE dist/macos-icons/sarasacw-picture.icns )
2026-09-24 16:05:20 +08:00
# Setup Info.plist related directory.
2026-09-28 14:38:57 +08:00
set ( SCWPIC_PLIST_OUTPUT_DIR ${ CMAKE_CURRENT_BINARY_DIR } /plist-metadata )
2026-09-24 16:05:20 +08:00
# Render Info.plist and its strings.
execute_process (
2026-10-09 20:09:04 +08:00
COMMAND ${ METAGLOT_EXECUTABLE } render plist
2026-09-24 16:05:20 +08:00
--manifest ${ CMAKE_SOURCE_DIR } /dist/Info.plist.in.toml
--po ${ CMAKE_SOURCE_DIR } /locales/plist/*.po
--plist-template ${ CMAKE_SOURCE_DIR } /dist/Info.plist.in.liquid
--strings-template ${ CMAKE_SOURCE_DIR } /dist/InfoPlist.strings.liquid
--plist-path Info.plist.in
--strings-path "Resources/{{ lang }}.lproj/InfoPlist.strings"
2026-09-28 14:38:57 +08:00
--output ${ SCWPIC_PLIST_OUTPUT_DIR }
2026-09-24 16:05:20 +08:00
RESULT_VARIABLE METAGLOT_PLIST_RESULT
)
if ( NOT METAGLOT_PLIST_RESULT EQUAL 0 )
message ( FATAL_ERROR "Failed to render Info.plist metadata via MetaGlot (exit code: ${METAGLOT_PLIST_RESULT})." )
endif ()
# Include these to project.
2026-09-28 14:38:57 +08:00
file ( GLOB SCWPIC_PLIST_STRINGS_FILES ${ SCWPIC_PLIST_OUTPUT_DIR } /Resources/*.lproj/InfoPlist.strings )
foreach ( plist_strings_file ${ SCWPIC_PLIST_STRINGS_FILES } )
2026-09-24 16:05:20 +08:00
get_filename_component ( plist_lproj_dir ${ plist_strings_file } DIRECTORY )
get_filename_component ( plist_lproj_name ${ plist_lproj_dir } NAME )
set_source_files_properties ( ${ plist_strings_file } PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources/${plist_lproj_name}"
)
target_sources ( ${ EXE_NAME } PRIVATE ${ plist_strings_file } )
endforeach ()
2024-12-02 00:25:48 +08:00
# See https://cmake.org/cmake/help/v3.15/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.html
set_target_properties ( ${ EXE_NAME } PROPERTIES
MACOSX_BUNDLE TRUE
2026-09-28 14:38:57 +08:00
MACOSX_BUNDLE_INFO_PLIST ${ SCWPIC_PLIST_OUTPUT_DIR } /Info.plist.in
MACOSX_BUNDLE_INFO_STRING "${PROJECT_VERSION}, Copyright (C) 2026 Sarasa's Chip Workshop"
MACOSX_BUNDLE_GUI_IDENTIFIER org.sarasaschipworkshop.picture
2026-09-22 13:53:16 +08:00
MACOSX_BUNDLE_ICON_FILE sarasacw-picture.icns # contains the .icns file name, *without* the path.
2024-12-02 00:25:48 +08:00
MACOSX_BUNDLE_BUNDLE_VERSION ${ PROJECT_VERSION }
2026-09-24 16:05:20 +08:00
MACOSX_BUNDLE_SHORT_VERSION_STRING ${ PROJECT_VERSION_MAJOR } . ${ PROJECT_VERSION_MINOR } . ${ PROJECT_VERSION_PATCH }
2024-12-02 00:25:48 +08:00
)
2020-01-03 23:01:12 +08:00
elseif ( UNIX )
2019-11-23 20:51:58 +08:00
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
set ( CMAKE_INSTALL_PREFIX /usr )
endif ()
# install icon
install (
2026-09-22 16:43:04 +08:00
DIRECTORY dist/freedesktop-icons/
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor"
2019-11-23 20:51:58 +08:00
)
2026-09-22 15:28:52 +08:00
# generate and install desktop entry file
2026-09-28 14:38:57 +08:00
set ( SCWPIC_DESKTOP_FILE ${ CMAKE_CURRENT_BINARY_DIR } /org.sarasaschipworkshop.picture.desktop )
2026-09-22 15:28:52 +08:00
execute_process (
2026-10-09 20:09:04 +08:00
COMMAND ${ METAGLOT_EXECUTABLE } render desktop
2026-09-28 14:38:57 +08:00
--manifest ${ CMAKE_SOURCE_DIR } /dist/org.sarasaschipworkshop.picture.desktop.toml
2026-09-22 15:28:52 +08:00
--po ${ CMAKE_SOURCE_DIR } /locales/desktop/*.po
2026-09-28 14:38:57 +08:00
--template ${ CMAKE_SOURCE_DIR } /dist/org.sarasaschipworkshop.picture.desktop.liquid
--output ${ SCWPIC_DESKTOP_FILE }
2026-09-22 15:28:52 +08:00
RESULT_VARIABLE METAGLOT_DESKTOP_RESULT
)
if ( NOT METAGLOT_DESKTOP_RESULT EQUAL 0 )
2026-09-22 17:15:49 +08:00
message ( FATAL_ERROR "Failed to generate .desktop via MetaGlot (exit code: ${METAGLOT_DESKTOP_RESULT})." )
2026-09-22 15:28:52 +08:00
endif ()
2019-11-23 20:51:58 +08:00
install (
2026-09-28 14:38:57 +08:00
FILES ${ SCWPIC_DESKTOP_FILE }
2019-11-23 20:51:58 +08:00
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications"
)
2020-09-14 18:34:30 +08:00
2026-09-22 16:06:23 +08:00
# generate and install app metadata file for appstream (and some other stuff using this metadata like snapcraft)
2026-09-28 14:38:57 +08:00
set ( SCWPIC_METAINFO_FILE ${ CMAKE_CURRENT_BINARY_DIR } /org.sarasaschipworkshop.picture.metainfo.xml )
2026-09-22 16:06:23 +08:00
execute_process (
2026-10-09 20:09:04 +08:00
COMMAND ${ METAGLOT_EXECUTABLE } render appstream
2026-09-28 14:38:57 +08:00
--manifest ${ CMAKE_SOURCE_DIR } /dist/org.sarasaschipworkshop.picture.metainfo.xml.toml
2026-09-22 16:06:23 +08:00
--po ${ CMAKE_SOURCE_DIR } /locales/appstream/*.po
2026-09-28 14:38:57 +08:00
--template ${ CMAKE_SOURCE_DIR } /dist/org.sarasaschipworkshop.picture.metainfo.xml.liquid
--output ${ SCWPIC_METAINFO_FILE }
2026-09-22 16:06:23 +08:00
RESULT_VARIABLE METAGLOT_METAINFO_RESULT
)
if ( NOT METAGLOT_METAINFO_RESULT EQUAL 0 )
2026-09-22 17:15:49 +08:00
message ( FATAL_ERROR "Failed to generate .metainfo.xml via MetaGlot (exit code: ${METAGLOT_METAINFO_RESULT})." )
2026-09-22 16:06:23 +08:00
endif ()
2020-09-14 18:34:30 +08:00
install (
2026-09-28 14:38:57 +08:00
FILES ${ SCWPIC_METAINFO_FILE }
2020-09-14 18:34:30 +08:00
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
)
2020-01-03 23:01:12 +08:00
endif ()
2019-11-23 20:51:58 +08:00
2020-01-03 23:01:12 +08:00
set ( INSTALL_TARGETS_DEFAULT_ARGS
2024-12-02 00:25:48 +08:00
BUNDLE DESTINATION .
2023-06-04 13:50:34 +08:00
RUNTIME DESTINATION ${ CMAKE_INSTALL_BINDIR }
LIBRARY DESTINATION ${ CMAKE_INSTALL_LIBDIR }
ARCHIVE DESTINATION ${ CMAKE_INSTALL_LIBDIR } COMPONENT Devel
2020-01-03 23:01:12 +08:00
)
install (
TARGETS ${ EXE_NAME }
${ INSTALL_TARGETS_DEFAULT_ARGS }
)
2024-12-24 22:37:16 +08:00
if ( TRANSLATION_RESOURCE_EMBEDDING )
target_compile_definitions ( ${ EXE_NAME }
PRIVATE TRANSLATION_RESOURCE_EMBEDDING
)
elseif ( WIN32 )
2020-01-03 23:01:12 +08:00
set ( QM_FILE_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}/translations" )
2024-12-24 22:37:16 +08:00
else ()
2026-09-28 14:38:57 +08:00
set ( QM_FILE_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/sarasacw-picture/translations" )
2020-01-05 14:30:33 +08:00
target_compile_definitions ( ${ EXE_NAME }
2024-12-24 22:37:16 +08:00
PRIVATE QM_FILE_INSTALL_ABSOLUTE_DIR= ${ QM_FILE_INSTALL_DIR }
2020-01-05 14:30:33 +08:00
)
2024-12-24 22:37:16 +08:00
endif ()
2020-01-03 23:01:12 +08:00
2024-12-24 22:37:16 +08:00
if ( DEFINED QM_FILE_INSTALL_DIR )
install (
2026-09-28 14:38:57 +08:00
FILES ${ SCWPIC_QM_FILES }
2024-12-24 22:37:16 +08:00
DESTINATION ${ QM_FILE_INSTALL_DIR }
)
endif ()
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" )
2026-09-28 14:38:57 +08:00
set ( CPACK_PACKAGE_NAME "sarasacw-picture" )
2020-01-03 23:01:12 +08:00
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Yet another image viewer" )
2026-09-28 14:38:57 +08:00
set ( CPACK_PACKAGE_VENDOR "Sarasa's Chip Workshop" )
set ( CPACK_PACKAGE_CONTACT "https://github.com/SarasasChipWorkshop/sarasacw-picture/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}" )
2024-04-28 00:12:44 +08:00
set ( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
2025-12-17 00:01:30 +08:00
set ( CPACK_DEBIAN_PACKAGE_RECOMMENDS "kimageformat6-plugins" )
2020-01-03 23:01:12 +08:00
endif ()
include ( CPack )