2025-07-10 10:10:53 +00:00
|
|
|
# Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2023-03-23 15:25:43 +00:00
|
|
|
|
2025-07-10 10:25:06 +00:00
|
|
|
#
|
|
|
|
# abstractviewer library
|
|
|
|
#
|
|
|
|
|
2023-11-06 08:56:14 +00:00
|
|
|
qt_add_library(abstractviewer
|
2023-06-08 12:51:24 +00:00
|
|
|
abstractviewer.cpp abstractviewer.h
|
2025-04-17 12:46:19 +00:00
|
|
|
translator.cpp translator.h
|
|
|
|
abstractviewerglobal.h
|
2023-06-08 12:51:24 +00:00
|
|
|
)
|
|
|
|
|
2023-11-06 08:56:14 +00:00
|
|
|
target_compile_definitions(abstractviewer PRIVATE BUILD_ABSTRACTVIEWER_LIB)
|
|
|
|
|
2025-07-10 10:05:41 +00:00
|
|
|
target_include_directories(abstractviewer INTERFACE .)
|
|
|
|
|
2025-07-10 10:25:06 +00:00
|
|
|
target_link_libraries(abstractviewer PRIVATE
|
|
|
|
Qt6::Core
|
|
|
|
Qt6::Gui
|
|
|
|
Qt6::Widgets
|
|
|
|
)
|
|
|
|
|
|
|
|
if(TARGET Qt6::PrintSupport)
|
|
|
|
target_link_libraries(abstractviewer PUBLIC Qt6::PrintSupport)
|
|
|
|
target_compile_definitions(abstractviewer PUBLIC
|
|
|
|
DOCUMENTVIEWER_PRINTSUPPORT
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#
|
|
|
|
# documentviewer library
|
|
|
|
#
|
|
|
|
|
2025-07-02 11:47:00 +00:00
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
|
2023-03-23 15:25:43 +00:00
|
|
|
qt_add_executable(documentviewer
|
|
|
|
main.cpp
|
|
|
|
mainwindow.cpp mainwindow.h mainwindow.ui
|
|
|
|
viewerfactory.cpp viewerfactory.h
|
|
|
|
recentfiles.cpp recentfiles.h
|
|
|
|
recentfilemenu.cpp recentfilemenu.h
|
|
|
|
viewerinterfaces.h
|
2023-06-27 11:56:05 +00:00
|
|
|
documentviewer.qrc
|
2023-03-23 15:25:43 +00:00
|
|
|
)
|
|
|
|
|
2025-04-17 12:46:19 +00:00
|
|
|
qt_add_translations(documentviewer
|
2025-07-11 16:10:15 +00:00
|
|
|
SOURCE_TARGETS documentviewer abstractviewer
|
2025-05-02 07:13:49 +00:00
|
|
|
TS_FILE_BASE docviewer
|
2025-04-17 12:46:19 +00:00
|
|
|
MERGE_QT_TRANSLATIONS
|
|
|
|
QT_TRANSLATION_CATALOGS qtbase
|
|
|
|
)
|
|
|
|
|
2023-03-23 15:25:43 +00:00
|
|
|
set_target_properties(documentviewer PROPERTIES
|
|
|
|
WIN32_EXECUTABLE TRUE
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(documentviewer PRIVATE
|
2023-05-02 10:25:58 +00:00
|
|
|
Qt6::Core
|
|
|
|
Qt6::Gui
|
|
|
|
Qt6::Widgets
|
2023-06-08 12:51:24 +00:00
|
|
|
abstractviewer
|
|
|
|
)
|
|
|
|
|
2025-07-10 10:40:43 +00:00
|
|
|
if (APPLE)
|
|
|
|
set_target_properties(documentviewer PROPERTIES
|
|
|
|
OUTPUT_NAME "Document Viewer"
|
|
|
|
MACOSX_BUNDLE TRUE
|
|
|
|
MACOSX_BUNDLE_BUNDLE_NAME "Document Viewer"
|
|
|
|
MACOSX_BUNDLE_COPYRIGHT "Copyright (C) The Qt Company Ltd. and other contributors."
|
|
|
|
MACOSX_BUNDLE_GUI_IDENTIFIER "io.qt.examples.documentviewer"
|
|
|
|
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
|
|
|
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2023-05-08 07:03:24 +00:00
|
|
|
set(plugin_targets
|
2025-07-10 15:04:14 +00:00
|
|
|
imageviewer
|
2023-05-08 07:03:24 +00:00
|
|
|
jsonviewer
|
|
|
|
txtviewer
|
|
|
|
)
|
|
|
|
|
|
|
|
if(TARGET pdfviewer)
|
|
|
|
list(APPEND plugin_targets pdfviewer)
|
|
|
|
endif()
|
|
|
|
|
2024-09-18 13:37:06 +00:00
|
|
|
if(TARGET Q3Dviewer)
|
|
|
|
list(APPEND plugin_targets Q3Dviewer)
|
2024-01-02 19:52:39 +00:00
|
|
|
endif()
|
|
|
|
|
2023-03-23 15:25:43 +00:00
|
|
|
if(QT6_IS_SHARED_LIBS_BUILD)
|
2023-05-08 07:03:24 +00:00
|
|
|
add_dependencies(documentviewer ${plugin_targets})
|
2023-03-23 15:25:43 +00:00
|
|
|
else()
|
2023-05-08 07:03:24 +00:00
|
|
|
target_link_libraries(documentviewer PRIVATE ${plugin_targets})
|
2023-03-23 15:25:43 +00:00
|
|
|
endif()
|
|
|
|
|
2025-07-10 10:25:06 +00:00
|
|
|
#
|
|
|
|
# installation
|
|
|
|
#
|
2023-03-23 15:25:43 +00:00
|
|
|
|
documentviewer: Fix deployment for macOS, Windows, Linux
Adapt the logic to install and detect especially the
plugins libs:
* Do not just compile them into the app build folder, but
keep the libs separate under the 'plugins' direcory
* At installation time, follow the logic of *deployqt
for Qt plugins, and store them in CMAKE_INSTALL_PREFIX/plugins
(Linux, Windows) or Document Viewer.app/Contents/Plugins
(macOS).
Unfortunately, this all requires different look ups at runtime for
all operating systems. For macOS and Windows, we furthermore need
to check both for valid paths with an installed build, and an
un-installed build.
While at it, move the install logic to app/CMakeLists.txt, so that
there is less repetition.
An alternative approach would be to calculate the relative paths
at configure time, and either pass on command line or in a created
header file. Anyhow, the current approach is more compact.
Pick-to: 6.10
Fixes: QTBUG-138476
Change-Id: I467d3bd4e14ef6b8b747bceb7177837e2edd3b8c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-07-10 15:04:37 +00:00
|
|
|
if(APPLE)
|
|
|
|
set(INSTALL_LIBDIR "Document Viewer.app/Contents/Frameworks")
|
|
|
|
set(INSTALL_PLUGINSDIR "Document Viewer.app/Contents/PlugIns")
|
|
|
|
elseif(WIN32)
|
|
|
|
set(INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
|
|
|
|
set(INSTALL_LIBDIR ${CMAKE_INSTALL_BINDIR})
|
|
|
|
set(INSTALL_PLUGINSDIR "plugins")
|
|
|
|
else()
|
|
|
|
set(INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
|
|
|
|
set(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
set(INSTALL_PLUGINSDIR "plugins")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
install(TARGETS documentviewer abstractviewer
|
|
|
|
BUNDLE DESTINATION .
|
|
|
|
RUNTIME DESTINATION "${INSTALL_BINDIR}"
|
|
|
|
LIBRARY DESTINATION "${INSTALL_LIBDIR}"
|
2023-03-23 15:25:43 +00:00
|
|
|
)
|
|
|
|
|
documentviewer: Fix deployment for macOS, Windows, Linux
Adapt the logic to install and detect especially the
plugins libs:
* Do not just compile them into the app build folder, but
keep the libs separate under the 'plugins' direcory
* At installation time, follow the logic of *deployqt
for Qt plugins, and store them in CMAKE_INSTALL_PREFIX/plugins
(Linux, Windows) or Document Viewer.app/Contents/Plugins
(macOS).
Unfortunately, this all requires different look ups at runtime for
all operating systems. For macOS and Windows, we furthermore need
to check both for valid paths with an installed build, and an
un-installed build.
While at it, move the install logic to app/CMakeLists.txt, so that
there is less repetition.
An alternative approach would be to calculate the relative paths
at configure time, and either pass on command line or in a created
header file. Anyhow, the current approach is more compact.
Pick-to: 6.10
Fixes: QTBUG-138476
Change-Id: I467d3bd4e14ef6b8b747bceb7177837e2edd3b8c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-07-10 15:04:37 +00:00
|
|
|
install(TARGETS ${plugin_targets}
|
|
|
|
DESTINATION "${INSTALL_PLUGINSDIR}"
|
2024-03-25 18:28:28 +00:00
|
|
|
)
|
documentviewer: Fix deployment for macOS, Windows, Linux
Adapt the logic to install and detect especially the
plugins libs:
* Do not just compile them into the app build folder, but
keep the libs separate under the 'plugins' direcory
* At installation time, follow the logic of *deployqt
for Qt plugins, and store them in CMAKE_INSTALL_PREFIX/plugins
(Linux, Windows) or Document Viewer.app/Contents/Plugins
(macOS).
Unfortunately, this all requires different look ups at runtime for
all operating systems. For macOS and Windows, we furthermore need
to check both for valid paths with an installed build, and an
un-installed build.
While at it, move the install logic to app/CMakeLists.txt, so that
there is less repetition.
An alternative approach would be to calculate the relative paths
at configure time, and either pass on command line or in a created
header file. Anyhow, the current approach is more compact.
Pick-to: 6.10
Fixes: QTBUG-138476
Change-Id: I467d3bd4e14ef6b8b747bceb7177837e2edd3b8c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-07-10 15:04:37 +00:00
|
|
|
|
|
|
|
# Install Qt libraries and plugins
|
|
|
|
qt_generate_deploy_app_script(
|
|
|
|
TARGET documentviewer
|
|
|
|
OUTPUT_SCRIPT deploy_script
|
|
|
|
NO_UNSUPPORTED_PLATFORM_ERROR
|
|
|
|
NO_TRANSLATIONS
|
|
|
|
)
|
|
|
|
|
|
|
|
install(SCRIPT ${deploy_script})
|