2023-11-24 18:15:31 +01:00
|
|
|
# Copyright (C) 2023 Jakub Melka
|
2022-08-14 17:50:52 +02:00
|
|
|
#
|
|
|
|
# This file is part of PDF4QT.
|
|
|
|
#
|
|
|
|
# PDF4QT is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# with the written consent of the copyright owner, any later version.
|
|
|
|
#
|
|
|
|
# PDF4QT is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
# along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
|
2024-06-29 14:20:35 +02:00
|
|
|
set(PDF4QT_VERSION 1.4.0)
|
2023-12-10 17:56:33 +01:00
|
|
|
message(STATUS "Build type - CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
|
2022-08-14 17:50:52 +02:00
|
|
|
|
|
|
|
project(PDF4QT VERSION ${PDF4QT_VERSION} LANGUAGES CXX)
|
|
|
|
|
2022-08-27 17:32:48 +02:00
|
|
|
option(PDF4QT_INSTALL_DEPENDENCIES "Install dependencies" ON)
|
2022-08-27 18:15:16 +02:00
|
|
|
option(PDF4QT_INSTALL_QT_DEPENDENCIES "Install Qt dependencies" ON)
|
|
|
|
|
|
|
|
add_compile_definitions(PDF4QT_PROJECT_VERSION="${PDF4QT_VERSION}")
|
2022-09-18 13:08:21 +02:00
|
|
|
add_compile_definitions(QT_NO_EMIT)
|
2022-08-27 17:32:48 +02:00
|
|
|
|
|
|
|
if(WIN32 AND MSVC)
|
|
|
|
option(PDF4QT_INSTALL_MSVC_REDISTRIBUTABLE "Install MSVC redistributable package" ON)
|
2022-08-29 13:57:31 +02:00
|
|
|
option(PDF4QT_INSTALL_PREPARE_WIX_INSTALLER "Prepare Wix installer for Windows" ON)
|
2022-08-27 17:32:48 +02:00
|
|
|
endif()
|
|
|
|
|
2023-12-18 20:11:06 +01:00
|
|
|
option(PDF4QT_BUILD_ONLY_CORE_LIBRARY "Build only core library" OFF)
|
2023-12-02 18:35:11 +01:00
|
|
|
|
2022-08-27 17:32:48 +02:00
|
|
|
set(PDF4QT_QT_ROOT "" CACHE PATH "Qt root directory")
|
|
|
|
|
|
|
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Installation directory" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2022-08-14 17:50:52 +02:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
2022-08-20 17:43:33 +02:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2023-12-18 20:11:06 +01:00
|
|
|
if(PDF4QT_BUILD_ONLY_CORE_LIBRARY)
|
|
|
|
find_package(Qt6 REQUIRED COMPONENTS Core Gui Svg Xml)
|
|
|
|
else()
|
|
|
|
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Svg Xml PrintSupport TextToSpeech Test)
|
2023-12-02 18:35:11 +01:00
|
|
|
endif()
|
|
|
|
|
2022-08-14 17:50:52 +02:00
|
|
|
qt_standard_project_setup()
|
|
|
|
|
2022-08-27 17:32:48 +02:00
|
|
|
find_package(OpenSSL REQUIRED)
|
2023-12-21 14:25:41 +01:00
|
|
|
find_package(lcms REQUIRED)
|
2022-08-20 17:43:33 +02:00
|
|
|
find_package(ZLIB REQUIRED)
|
2023-12-13 11:05:29 +01:00
|
|
|
find_package(Freetype REQUIRED)
|
2022-08-20 17:43:33 +02:00
|
|
|
find_package(OpenJPEG CONFIG REQUIRED)
|
|
|
|
find_package(JPEG REQUIRED)
|
2022-10-08 15:12:09 +02:00
|
|
|
find_package(PNG REQUIRED)
|
2024-02-04 18:05:38 +01:00
|
|
|
find_package(blend2d CONFIG REQUIRED)
|
2022-08-20 17:43:33 +02:00
|
|
|
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
|
|
|
|
set(CMAKE_AUTORCC_OPTIONS "--threshold;0;--compress;9")
|
|
|
|
|
|
|
|
if (MSVC)
|
2022-09-17 13:56:41 +02:00
|
|
|
add_compile_options(/bigobj /W4 /wd5054 /wd4127 /wd4702)
|
2022-09-11 17:54:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (MINGW)
|
|
|
|
add_compile_options("-Wa,-mbig-obj")
|
2022-08-27 17:32:48 +02:00
|
|
|
endif()
|
2022-08-20 17:43:33 +02:00
|
|
|
|
2022-09-18 13:08:21 +02:00
|
|
|
if (UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
set(LINUX_GCC ON)
|
|
|
|
endif()
|
|
|
|
|
2023-09-17 18:20:11 +02:00
|
|
|
if (UNIX AND NOT APPLE)
|
|
|
|
set(PDF4QT_LINUX ON)
|
|
|
|
endif()
|
|
|
|
|
2023-09-08 16:08:07 +02:00
|
|
|
if (LINUX_GCC)
|
|
|
|
find_package(TBB REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2023-12-02 18:35:11 +01:00
|
|
|
option(PDF4QT_INSTALL_TO_USR "Install to usr directory" ON)
|
2023-09-23 18:07:38 +02:00
|
|
|
|
|
|
|
if(PDF4QT_LINUX)
|
|
|
|
set(PDF4QT_INSTALL_LIB_DIR_IMPL lib)
|
|
|
|
set(PDF4QT_INSTALL_BIN_DIR_IMPL bin)
|
2024-01-07 11:41:45 +01:00
|
|
|
|
|
|
|
# Check if VCPKG_OVERLAY_PORTS is set as an environment variable or a CMake argument
|
|
|
|
if(NOT DEFINED ENV{VCPKG_OVERLAY_PORTS} AND NOT DEFINED VCPKG_OVERLAY_PORTS)
|
|
|
|
message(WARNING "The VCPKG_OVERLAY_PORTS variable is not set! Application can crash in Open/Save dialog due to incompatible LIBPNG.")
|
|
|
|
else()
|
|
|
|
set(VCPKG_OVERLAY_PORTS_VALUE "$ENV{VCPKG_OVERLAY_PORTS}")
|
|
|
|
if(DEFINED VCPKG_OVERLAY_PORTS)
|
|
|
|
set(VCPKG_OVERLAY_PORTS_VALUE "${VCPKG_OVERLAY_PORTS}")
|
|
|
|
endif()
|
|
|
|
message(STATUS "The VCPKG_OVERLAY_PORTS variable is set to: ${VCPKG_OVERLAY_PORTS_VALUE}")
|
|
|
|
endif()
|
|
|
|
|
2023-09-23 18:07:38 +02:00
|
|
|
else()
|
|
|
|
set(PDF4QT_INSTALL_LIB_DIR_IMPL bin)
|
|
|
|
set(PDF4QT_INSTALL_BIN_DIR_IMPL bin)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(PDF4QT_INSTALL_TO_USR)
|
|
|
|
set(PDF4QT_INSTALL_LIB_DIR usr/${PDF4QT_INSTALL_LIB_DIR_IMPL})
|
|
|
|
set(PDF4QT_INSTALL_BIN_DIR usr/${PDF4QT_INSTALL_BIN_DIR_IMPL})
|
|
|
|
set(PDF4QT_INSTALL_SHARE_DIR usr/share)
|
|
|
|
else()
|
|
|
|
set(PDF4QT_INSTALL_LIB_DIR ${PDF4QT_INSTALL_LIB_DIR_IMPL})
|
|
|
|
set(PDF4QT_INSTALL_BIN_DIR ${PDF4QT_INSTALL_BIN_DIR_IMPL})
|
|
|
|
set(PDF4QT_INSTALL_SHARE_DIR share)
|
|
|
|
endif()
|
|
|
|
|
2023-12-03 19:11:17 +01:00
|
|
|
add_subdirectory(Pdf4QtLibCore)
|
2023-12-18 20:11:06 +01:00
|
|
|
|
|
|
|
if(NOT PDF4QT_BUILD_ONLY_CORE_LIBRARY)
|
|
|
|
add_subdirectory(Pdf4QtLibWidgets)
|
|
|
|
add_subdirectory(CodeGenerator)
|
|
|
|
add_subdirectory(JBIG2_Viewer)
|
|
|
|
add_subdirectory(PdfExampleGenerator)
|
|
|
|
add_subdirectory(PdfTool)
|
|
|
|
add_subdirectory(UnitTests)
|
2024-03-16 17:02:44 +01:00
|
|
|
add_subdirectory(Pdf4QtLibGui)
|
|
|
|
add_subdirectory(Pdf4QtEditorPlugins)
|
|
|
|
add_subdirectory(Pdf4QtEditor)
|
2023-12-18 20:11:06 +01:00
|
|
|
add_subdirectory(Pdf4QtViewer)
|
2024-03-16 17:02:44 +01:00
|
|
|
add_subdirectory(Pdf4QtPageMaster)
|
|
|
|
add_subdirectory(Pdf4QtDiff)
|
2024-03-17 13:29:24 +01:00
|
|
|
add_subdirectory(Pdf4QtLaunchPad)
|
2023-12-18 20:11:06 +01:00
|
|
|
add_subdirectory(WixInstaller)
|
|
|
|
endif()
|
2022-08-14 17:50:52 +02:00
|
|
|
|
|
|
|
message("CMAKE_PREFIX_PATH = " ${CMAKE_PREFIX_PATH})
|
|
|
|
message("CMAKE_TOOLCHAIN_FILE = " ${CMAKE_TOOLCHAIN_FILE})
|
|
|
|
|
2023-12-18 20:11:06 +01:00
|
|
|
if(NOT PDF4QT_BUILD_ONLY_CORE_LIBRARY)
|
2024-06-29 14:20:35 +02:00
|
|
|
if(WIN32)
|
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Desktop/44x44/
|
|
|
|
RUNTIME DESTINATION ${PDF4QT_INSTALL_BIN_DIR}/assets/44x44
|
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN *.png)
|
|
|
|
|
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Desktop/150x150/
|
|
|
|
RUNTIME DESTINATION ${PDF4QT_INSTALL_BIN_DIR}/assets/150x150
|
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN *.png)
|
|
|
|
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/AppxManifest.xml.in ${CMAKE_CURRENT_BINARY_DIR}/AppxManifest.xml)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/AppxManifest.xml DESTINATION ${PDF4QT_INSTALL_BIN_DIR})
|
|
|
|
install(FILES assets/logo.png DESTINATION ${PDF4QT_INSTALL_BIN_DIR}/assets)
|
|
|
|
else()
|
|
|
|
configure_file(make-package.sh.in make-package.sh)
|
|
|
|
|
|
|
|
install(FILES Desktop/io.github.JakubMelka.Pdf4qt.Pdf4QtDiff.desktop
|
|
|
|
Desktop/io.github.JakubMelka.Pdf4qt.Pdf4QtPageMaster.desktop
|
|
|
|
Desktop/io.github.JakubMelka.Pdf4qt.Pdf4QtViewer.desktop
|
|
|
|
Desktop/io.github.JakubMelka.Pdf4qt.Pdf4QtEditor.desktop
|
|
|
|
Desktop/io.github.JakubMelka.Pdf4qt.desktop
|
|
|
|
DESTINATION ${PDF4QT_INSTALL_SHARE_DIR}/applications)
|
|
|
|
install(FILES Desktop/io.github.JakubMelka.Pdf4qt.Pdf4QtDiff.svg
|
|
|
|
Desktop/io.github.JakubMelka.Pdf4qt.Pdf4QtPageMaster.svg
|
|
|
|
Desktop/io.github.JakubMelka.Pdf4qt.Pdf4QtViewer.svg
|
|
|
|
Desktop/io.github.JakubMelka.Pdf4qt.Pdf4QtEditor.svg
|
|
|
|
Desktop/io.github.JakubMelka.Pdf4qt.svg
|
|
|
|
DESTINATION ${PDF4QT_INSTALL_SHARE_DIR}/icons/hicolor/scalable/apps)
|
|
|
|
install(FILES Desktop/io.github.JakubMelka.Pdf4qt.appdata.xml DESTINATION ${PDF4QT_INSTALL_SHARE_DIR}/metainfo)
|
|
|
|
install(FILES Desktop/128x128/io.github.JakubMelka.Pdf4qt.Pdf4QtDiff.png
|
|
|
|
Desktop/128x128/io.github.JakubMelka.Pdf4qt.Pdf4QtPageMaster.png
|
|
|
|
Desktop/128x128/io.github.JakubMelka.Pdf4qt.Pdf4QtViewer.png
|
|
|
|
Desktop/128x128/io.github.JakubMelka.Pdf4qt.Pdf4QtEditor.png
|
|
|
|
Desktop/128x128/io.github.JakubMelka.Pdf4qt.png
|
|
|
|
DESTINATION ${PDF4QT_INSTALL_SHARE_DIR}/icons/hicolor/128x128/apps)
|
|
|
|
endif()
|
|
|
|
|
2023-12-18 20:11:06 +01:00
|
|
|
endif()
|
2023-07-30 16:44:40 +02:00
|
|
|
|
2023-12-18 20:11:06 +01:00
|
|
|
if(PDF4QT_INSTALL_DEPENDENCIES AND NOT PDF4QT_BUILD_ONLY_CORE_LIBRARY)
|
2022-08-27 17:32:48 +02:00
|
|
|
install(DIRECTORY ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/
|
2023-09-23 18:07:38 +02:00
|
|
|
RUNTIME DESTINATION ${PDF4QT_INSTALL_LIB_DIR}/
|
2022-08-27 17:32:48 +02:00
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.dll"
|
|
|
|
PATTERN "*.so"
|
|
|
|
PATTERN "*.dylib"
|
|
|
|
)
|
|
|
|
|
2022-09-01 17:59:29 +02:00
|
|
|
if("${PDF4QT_QT_ROOT}" STREQUAL "")
|
|
|
|
message(WARNING "Set variable PDF4QT_QT_ROOT to Qt6 root directory")
|
|
|
|
endif()
|
|
|
|
|
2022-08-27 17:32:48 +02:00
|
|
|
if(PDF4QT_INSTALL_QT_DEPENDENCIES)
|
|
|
|
install(DIRECTORY ${PDF4QT_QT_ROOT}/bin/
|
2023-09-23 18:07:38 +02:00
|
|
|
RUNTIME DESTINATION ${PDF4QT_INSTALL_LIB_DIR}/
|
2022-08-27 17:32:48 +02:00
|
|
|
FILES_MATCHING
|
2024-02-04 18:05:38 +01:00
|
|
|
REGEX "(Qt6Core|Qt6Gui|Qt6PrintSupport|Qt6Svg|Qt6TextToSpeech|Qt6Widgets|Qt6Xml|Qt6Multimedia|Qt6Network)\\..*"
|
2022-08-27 17:32:48 +02:00
|
|
|
PATTERN "Debug" EXCLUDE
|
2024-06-29 14:20:35 +02:00
|
|
|
PATTERN "*.pdb" EXCLUDE
|
2022-08-27 17:32:48 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY ${PDF4QT_QT_ROOT}/plugins/platforms/
|
2023-09-23 18:07:38 +02:00
|
|
|
RUNTIME DESTINATION ${PDF4QT_INSTALL_LIB_DIR}/platforms/
|
2022-08-27 17:32:48 +02:00
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "qwindows.dll"
|
|
|
|
PATTERN "*.so"
|
|
|
|
PATTERN "*.dylib"
|
2024-06-29 14:20:35 +02:00
|
|
|
PATTERN "*.pdb" EXCLUDE
|
2022-08-27 17:32:48 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY ${PDF4QT_QT_ROOT}/plugins/iconengines/
|
2023-09-23 18:07:38 +02:00
|
|
|
RUNTIME DESTINATION ${PDF4QT_INSTALL_LIB_DIR}/iconengines/
|
2022-08-27 17:32:48 +02:00
|
|
|
FILES_MATCHING
|
|
|
|
REGEX "qsvgicon\\..*"
|
2024-06-29 14:20:35 +02:00
|
|
|
PATTERN "*.pdb" EXCLUDE
|
2022-08-27 17:32:48 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY ${PDF4QT_QT_ROOT}/plugins/imageformats/
|
2023-09-23 18:07:38 +02:00
|
|
|
RUNTIME DESTINATION ${PDF4QT_INSTALL_LIB_DIR}/imageformats/
|
2022-08-27 17:32:48 +02:00
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.dll"
|
|
|
|
PATTERN "*.so"
|
|
|
|
PATTERN "*.dylib"
|
|
|
|
REGEX "d\\..*" EXCLUDE
|
2024-06-29 14:20:35 +02:00
|
|
|
PATTERN "*.pdb" EXCLUDE
|
2022-08-27 17:32:48 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY ${PDF4QT_QT_ROOT}/plugins/styles/
|
2023-09-23 18:07:38 +02:00
|
|
|
RUNTIME DESTINATION ${PDF4QT_INSTALL_LIB_DIR}/styles/
|
2022-08-27 17:32:48 +02:00
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.dll"
|
|
|
|
PATTERN "*.so"
|
|
|
|
PATTERN "*.dylib"
|
|
|
|
REGEX "d\\..*" EXCLUDE
|
2024-06-29 14:20:35 +02:00
|
|
|
PATTERN "*.pdb" EXCLUDE
|
2022-08-27 17:32:48 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY ${PDF4QT_QT_ROOT}/plugins/texttospeech/
|
2023-09-23 18:07:38 +02:00
|
|
|
RUNTIME DESTINATION ${PDF4QT_INSTALL_LIB_DIR}/texttospeech/
|
2022-08-27 17:32:48 +02:00
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.dll"
|
|
|
|
PATTERN "*.so"
|
|
|
|
PATTERN "*.dylib"
|
|
|
|
REGEX "d\\..*" EXCLUDE
|
2024-06-29 14:20:35 +02:00
|
|
|
PATTERN "*.pdb" EXCLUDE
|
2022-08-27 17:32:48 +02:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WIN32 AND MSVC AND PDF4QT_INSTALL_MSVC_REDISTRIBUTABLE)
|
2022-08-27 18:15:16 +02:00
|
|
|
get_filename_component(MSVC_REDISTRIBUTABLES_PATH $ENV{VCToolsRedistDir}/$ENV{VSCMD_ARG_TGT_ARCH}/Microsoft.VC${MSVC_TOOLSET_VERSION}.CRT/ ABSOLUTE)
|
|
|
|
message(STATUS "MSVC Redistributable Package Path = ${MSVC_REDISTRIBUTABLES_PATH}")
|
|
|
|
|
|
|
|
install(DIRECTORY ${MSVC_REDISTRIBUTABLES_PATH}/
|
2023-09-23 18:07:38 +02:00
|
|
|
RUNTIME DESTINATION ${PDF4QT_INSTALL_LIB_DIR}/
|
2022-08-27 18:15:16 +02:00
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.dll"
|
|
|
|
)
|
2022-08-27 17:32:48 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
2022-08-14 17:50:52 +02:00
|
|
|
|
|
|
|
#macro(dump_variables)
|
|
|
|
# message(STATUS "dump_variables------------------------------------------{")
|
|
|
|
# get_cmake_property(_variableNames VARIABLES)
|
|
|
|
# foreach (_variableName ${_variableNames})
|
|
|
|
# message(STATUS "${_variableName}=${${_variableName}}")
|
|
|
|
# endforeach()
|
|
|
|
# message(STATUS "dump_variables------------------------------------------}")
|
|
|
|
#endmacro()
|
|
|
|
#
|
|
|
|
#dump_variables()
|
2022-08-20 17:43:33 +02:00
|
|
|
|