PDF4QT/CMakeLists.txt

181 lines
6.0 KiB
CMake
Raw Normal View History

2022-08-14 17:50:52 +02:00
# Copyright (C) 2022 Jakub Melka
#
# 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)
2023-04-22 15:08:58 +02:00
set(PDF4QT_VERSION 1.3.3)
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)
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()
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)
include(GNUInstallDirs)
2022-08-27 17:32:48 +02:00
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Svg Xml PrintSupport TextToSpeech OpenGL OpenGLWidgets Multimedia Network Test)
2022-08-14 17:50:52 +02:00
qt_standard_project_setup()
2022-08-27 17:32:48 +02:00
find_package(OpenSSL REQUIRED)
find_package(lcms REQUIRED)
find_package(ZLIB REQUIRED)
find_package(freetype CONFIG REQUIRED)
find_package(OpenJPEG CONFIG REQUIRED)
find_package(JPEG REQUIRED)
2022-10-08 15:12:09 +02:00
find_package(PNG REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTORCC_OPTIONS "--threshold;0;--compress;9")
if (MSVC)
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-09-18 13:08:21 +02:00
if (UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCXX)
set(LINUX_GCC ON)
endif()
2022-08-14 17:50:52 +02:00
add_subdirectory(Pdf4QtLib)
add_subdirectory(CodeGenerator)
add_subdirectory(JBIG2_Viewer)
add_subdirectory(PdfExampleGenerator)
add_subdirectory(PdfTool)
add_subdirectory(UnitTests)
add_subdirectory(Pdf4QtViewer)
add_subdirectory(Pdf4QtViewerPlugins)
add_subdirectory(Pdf4QtViewerProfi)
add_subdirectory(Pdf4QtViewerLite)
add_subdirectory(Pdf4QtDocPageOrganizer)
add_subdirectory(Pdf4QtDocDiff)
2022-08-29 13:57:31 +02:00
add_subdirectory(WixInstaller)
2022-08-14 17:50:52 +02:00
message("CMAKE_PREFIX_PATH = " ${CMAKE_PREFIX_PATH})
message("CMAKE_TOOLCHAIN_FILE = " ${CMAKE_TOOLCHAIN_FILE})
2022-08-27 17:32:48 +02:00
if(PDF4QT_INSTALL_DEPENDENCIES)
install(DIRECTORY ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/
TYPE BIN
FILES_MATCHING
PATTERN "*.dll"
PATTERN "*.so"
PATTERN "*.dylib"
)
2023-06-23 20:54:51 +02:00
install(FILES Desktop/Pdf4QtDocDiff.desktop Desktop/Pdf4QtDocPageOrganizer.desktop Desktop/Pdf4QtViewerLite.desktop Desktop/Pdf4QtViewerProfi.desktop DESTINATION usr/share/applications)
install(FILES Desktop/Pdf4QtDocDiff.svg Desktop/Pdf4QtDocPageOrganizer.svg Desktop/Pdf4QtViewerLite.svg Desktop/Pdf4QtViewerProfi.svg DESTINATION usr/share/icons)
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/
RUNTIME DESTINATION bin/
FILES_MATCHING
REGEX "(Qt6Core|Qt6Gui|Qt6PrintSupport|Qt6Svg|Qt6TextToSpeech|Qt6Widgets|Qt6Xml|Qt6OpenGL|Qt6OpenGLWidgets|Qt6Multimedia|Qt6Network)\\..*"
PATTERN "Debug" EXCLUDE
)
install(DIRECTORY ${PDF4QT_QT_ROOT}/plugins/platforms/
RUNTIME DESTINATION bin/platforms/
FILES_MATCHING
PATTERN "qwindows.dll"
PATTERN "*.so"
PATTERN "*.dylib"
)
install(DIRECTORY ${PDF4QT_QT_ROOT}/plugins/iconengines/
RUNTIME DESTINATION bin/iconengines/
FILES_MATCHING
REGEX "qsvgicon\\..*"
)
install(DIRECTORY ${PDF4QT_QT_ROOT}/plugins/imageformats/
RUNTIME DESTINATION bin/imageformats/
FILES_MATCHING
PATTERN "*.dll"
PATTERN "*.so"
PATTERN "*.dylib"
REGEX "d\\..*" EXCLUDE
)
install(DIRECTORY ${PDF4QT_QT_ROOT}/plugins/styles/
RUNTIME DESTINATION bin/styles/
FILES_MATCHING
PATTERN "*.dll"
PATTERN "*.so"
PATTERN "*.dylib"
REGEX "d\\..*" EXCLUDE
)
install(DIRECTORY ${PDF4QT_QT_ROOT}/plugins/texttospeech/
RUNTIME DESTINATION bin/texttospeech/
FILES_MATCHING
PATTERN "*.dll"
PATTERN "*.so"
PATTERN "*.dylib"
REGEX "d\\..*" EXCLUDE
)
endif()
if(WIN32 AND MSVC AND PDF4QT_INSTALL_MSVC_REDISTRIBUTABLE)
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}/
RUNTIME DESTINATION bin/
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()