mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-20 07:14:13 +02:00
Removing Qt5/KF5 from build system.
This commit is contained in:
+46
-97
@@ -28,25 +28,6 @@ include(cmake/copyright_message.cmake)
|
||||
|
||||
set(QET_DIR ${PROJECT_SOURCE_DIR})
|
||||
|
||||
# QT_VERSION_MAJOR is chosen explicitly by whoever configures the build,
|
||||
# via -DQT_VERSION_MAJOR=5 or -DQT_VERSION_MAJOR=6.
|
||||
# Default to Qt5 (current stable) when not specified, so existing
|
||||
# CI/scripts that don't pass this option keep working unchanged.
|
||||
# This must happen BEFORE add_subdirectory(tests) and the fetch_*.cmake
|
||||
# includes below, so every subdirectory and every FetchContent dependency
|
||||
# sees a consistent, already-defined value.
|
||||
if(NOT DEFINED QT_VERSION_MAJOR)
|
||||
set(QT_VERSION_MAJOR 6)
|
||||
endif()
|
||||
|
||||
# Some third-party CMake projects we pull in via FetchContent (e.g.
|
||||
# SingleApplication) don't know about QET_VERSION_MAJOR: they follow Qt's
|
||||
# own "QT_DEFAULT_MAJOR_VERSION" convention instead, and silently default
|
||||
# to Qt5 if it isn't set. Propagate our choice so they stay in sync,
|
||||
# otherwise they can end up linked against a different Qt major version
|
||||
# than the rest of QET, which breaks AUTOMOC with an
|
||||
# INTERFACE_QT_MAJOR_VERSION mismatch at generate time.
|
||||
set(QT_DEFAULT_MAJOR_VERSION ${QT_VERSION_MAJOR} CACHE STRING "Qt version to use (5 or 6)" FORCE)
|
||||
|
||||
include(cmake/paths_compilation_installation.cmake)
|
||||
include(cmake/start_options.cmake)
|
||||
@@ -65,7 +46,7 @@ SET(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
Qt6
|
||||
COMPONENTS
|
||||
${QET_COMPONENTS}
|
||||
REQUIRED)
|
||||
@@ -76,12 +57,9 @@ find_package(
|
||||
# and only provide the implicit Qt6::GuiPrivate target created alongside
|
||||
# Qt6::Gui. Try the component quietly, then verify the target below so a
|
||||
# missing private-headers package fails here instead of at compile time.
|
||||
# Qt5 has no such component as its GuiPrivate target always exists once Gui is found.
|
||||
if(QT_VERSION_MAJOR GREATER_EQUAL 6)
|
||||
find_package(Qt6 QUIET COMPONENTS GuiPrivate)
|
||||
endif()
|
||||
find_package(Qt6 QUIET COMPONENTS GuiPrivate)
|
||||
|
||||
if(QT_VERSION_MAJOR GREATER_EQUAL 6 AND NOT TARGET Qt6::GuiPrivate)
|
||||
if(NOT TARGET Qt6::GuiPrivate)
|
||||
message(FATAL_ERROR
|
||||
"Qt6::GuiPrivate was not found. It is required for PDF hyperlink "
|
||||
"support (<private/qpdf_p.h>). Install the Qt6 private headers "
|
||||
@@ -98,15 +76,13 @@ endif()
|
||||
# see the QT_VERSION_CHECK / QET_HAS_QTPDF guards in diagrameventaddpdf.*
|
||||
# and pdfpagesdialog.*.
|
||||
set(QET_HAS_QTPDF FALSE)
|
||||
if(QT_VERSION_MAJOR GREATER_EQUAL 6)
|
||||
find_package(Qt6 QUIET COMPONENTS Pdf)
|
||||
if(TARGET Qt6::Pdf AND NOT Qt6_VERSION VERSION_LESS 6.4.0)
|
||||
set(QET_HAS_QTPDF TRUE)
|
||||
list(APPEND QET_PRIVATE_LIBRARIES Qt::Pdf)
|
||||
add_compile_definitions(QET_HAS_QTPDF)
|
||||
else()
|
||||
message(STATUS "QtPdf module not available (or Qt < 6.4): PDF page import feature disabled")
|
||||
endif()
|
||||
find_package(Qt6 QUIET COMPONENTS Pdf)
|
||||
if(TARGET Qt6::Pdf AND NOT Qt6_VERSION VERSION_LESS 6.4.0)
|
||||
set(QET_HAS_QTPDF TRUE)
|
||||
list(APPEND QET_PRIVATE_LIBRARIES Qt::Pdf)
|
||||
add_compile_definitions(QET_HAS_QTPDF)
|
||||
else()
|
||||
message(STATUS "QtPdf module not available (or Qt < 6.4): PDF page import feature disabled")
|
||||
endif()
|
||||
|
||||
# JavaScript scripting (bugtracker #162: `--run script.js`, and later a
|
||||
@@ -139,11 +115,6 @@ endif()
|
||||
|
||||
set(CMAKE_AUTOUIC_SEARCH_PATHS ${QET_DIR}/sources/ui)
|
||||
|
||||
if(QT_VERSION_MAJOR EQUAL 6)
|
||||
set(KF_MAJOR_VERSION 6)
|
||||
else()
|
||||
set(KF_MAJOR_VERSION 5)
|
||||
endif()
|
||||
include(cmake/fetch_kdeaddons.cmake)
|
||||
|
||||
# Add sub directories
|
||||
@@ -208,71 +179,19 @@ set_source_files_properties(
|
||||
${TS_FILES}
|
||||
PROPERTIES OUTPUT_LOCATION "lang"
|
||||
)
|
||||
if(QT_VERSION_MAJOR EQUAL 6)
|
||||
if(Qt6_VERSION VERSION_LESS "6.2")
|
||||
# Qt 6.0–6.1
|
||||
qt6_add_translation(QM_FILES ${TS_FILES})
|
||||
if(Qt6_VERSION VERSION_LESS "6.2")
|
||||
# Qt 6.0–6.1
|
||||
qt6_add_translation(QM_FILES ${TS_FILES})
|
||||
|
||||
# qt6_add_translation() only creates custom commands. Something must
|
||||
# depend on their outputs for them to run during the default build.
|
||||
add_custom_target(${PROJECT_NAME}_lrelease ALL
|
||||
DEPENDS ${QM_FILES}
|
||||
)
|
||||
|
||||
add_custom_target(update_translations
|
||||
COMMAND
|
||||
$<TARGET_FILE:Qt6::lupdate>
|
||||
"${CMAKE_SOURCE_DIR}/sources"
|
||||
-ts ${TS_FILES}
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
COMMENT
|
||||
"Updating .ts files from sources/ (lupdate) - developer target"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
elseif(Qt6_VERSION VERSION_LESS "6.7")
|
||||
# Qt 6.2–6.6: old target-based signature
|
||||
qt_add_lrelease(
|
||||
${PROJECT_NAME}
|
||||
TS_FILES ${TS_FILES}
|
||||
QM_FILES_OUTPUT_VARIABLE QM_FILES
|
||||
)
|
||||
|
||||
# Automatically creates the update_translations umbrella target.
|
||||
qt_add_lupdate(
|
||||
${PROJECT_NAME}
|
||||
TS_FILES ${TS_FILES}
|
||||
)
|
||||
|
||||
else()
|
||||
# Qt 6.7+: new signature
|
||||
qt_add_lrelease(
|
||||
TS_FILES ${TS_FILES}
|
||||
LRELEASE_TARGET ${PROJECT_NAME}_lrelease
|
||||
QM_FILES_OUTPUT_VARIABLE QM_FILES
|
||||
)
|
||||
|
||||
qt_add_lupdate(
|
||||
SOURCE_TARGETS ${PROJECT_NAME}
|
||||
TS_FILES ${TS_FILES}
|
||||
LUPDATE_TARGET update_translations
|
||||
NO_GLOBAL_TARGET
|
||||
)
|
||||
endif()
|
||||
|
||||
else()
|
||||
# Qt 5
|
||||
qt5_add_translation(QM_FILES ${TS_FILES})
|
||||
|
||||
# Likewise, qt5_add_translation() needs a target depending on its outputs,
|
||||
# unless QM_FILES are already consumed elsewhere.
|
||||
# qt6_add_translation() only creates custom commands. Something must
|
||||
# depend on their outputs for them to run during the default build.
|
||||
add_custom_target(${PROJECT_NAME}_lrelease ALL
|
||||
DEPENDS ${QM_FILES}
|
||||
)
|
||||
|
||||
add_custom_target(update_translations
|
||||
COMMAND
|
||||
$<TARGET_FILE:Qt5::lupdate>
|
||||
$<TARGET_FILE:Qt6::lupdate>
|
||||
"${CMAKE_SOURCE_DIR}/sources"
|
||||
-ts ${TS_FILES}
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
@@ -280,8 +199,38 @@ else()
|
||||
"Updating .ts files from sources/ (lupdate) - developer target"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
elseif(Qt6_VERSION VERSION_LESS "6.7")
|
||||
# Qt 6.2–6.6: old target-based signature
|
||||
qt_add_lrelease(
|
||||
${PROJECT_NAME}
|
||||
TS_FILES ${TS_FILES}
|
||||
QM_FILES_OUTPUT_VARIABLE QM_FILES
|
||||
)
|
||||
|
||||
# Automatically creates the update_translations umbrella target.
|
||||
qt_add_lupdate(
|
||||
${PROJECT_NAME}
|
||||
TS_FILES ${TS_FILES}
|
||||
)
|
||||
|
||||
else()
|
||||
# Qt 6.7+: new signature
|
||||
qt_add_lrelease(
|
||||
TS_FILES ${TS_FILES}
|
||||
LRELEASE_TARGET ${PROJECT_NAME}_lrelease
|
||||
QM_FILES_OUTPUT_VARIABLE QM_FILES
|
||||
)
|
||||
|
||||
qt_add_lupdate(
|
||||
SOURCE_TARGETS ${PROJECT_NAME}
|
||||
TS_FILES ${TS_FILES}
|
||||
LUPDATE_TARGET update_translations
|
||||
NO_GLOBAL_TARGET
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# Optional precompiled headers -- see QET_ENABLE_PCH in
|
||||
# cmake/developer_options.cmake for what this trades away.
|
||||
#
|
||||
|
||||
@@ -68,4 +68,3 @@ else()
|
||||
add_definitions(-DBUILD_WITHOUT_KF)
|
||||
endif()
|
||||
message("QET_COMPONENTS :" ${QET_COMPONENTS})
|
||||
message("QT_VERSION_MAJOR :" ${QT_VERSION_MAJOR})
|
||||
|
||||
@@ -31,10 +31,7 @@ add_definitions(-DQT_MESSAGELOGCONTEXT)
|
||||
# In order to do so, uncomment the following line.
|
||||
#add_definitions(-DTODO_LIST)
|
||||
|
||||
# Build with KDE Frameworks. The major version (KF5/KF6) is derived
|
||||
# automatically from QT_VERSION_MAJOR -- KDE Frameworks deliberately
|
||||
# mirrors Qt's own major version numbering, so there is no independent
|
||||
# choice to make here. See cmake/fetch_kdeaddons.cmake.
|
||||
# Build with KDE Frameworks.
|
||||
option(BUILD_WITH_KF "Build with KDE Frameworks" ON)
|
||||
|
||||
# Precompiled headers for the Qt umbrella headers.
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
message(" - fetch_kdeaddons")
|
||||
|
||||
# TODO remove path as soon as Qt5 gets retired
|
||||
if(BUILD_WITH_KF)
|
||||
Include(FetchContent)
|
||||
|
||||
@@ -24,16 +23,9 @@ if(BUILD_WITH_KF)
|
||||
|
||||
if(BUILD_KF)
|
||||
|
||||
if(KF_MAJOR_VERSION EQUAL 5)
|
||||
if(NOT DEFINED KF_GIT_TAG)
|
||||
#https://qelectrotech.org/forum/viewtopic.php?pid=13924#p13924
|
||||
set(KF_GIT_TAG v5.77.0)
|
||||
endif()
|
||||
else()
|
||||
if(NOT DEFINED KF_GIT_TAG)
|
||||
# this is a more or less random version, taken as an conservative approach
|
||||
set(KF_GIT_TAG v6.10.0)
|
||||
endif()
|
||||
if(NOT DEFINED KF_GIT_TAG)
|
||||
# this is a more or less random version, taken as an conservative approach
|
||||
set(KF_GIT_TAG v6.10.0)
|
||||
endif()
|
||||
# using a function in order to limit the scope of the variables
|
||||
# with CMake >=3.25 we could use a block()
|
||||
@@ -78,12 +70,12 @@ if(BUILD_WITH_KF)
|
||||
endfunction()
|
||||
qet_make_kf_available()
|
||||
else()
|
||||
find_package(KF${KF_MAJOR_VERSION}CoreAddons REQUIRED)
|
||||
find_package(KF${KF_MAJOR_VERSION}WidgetsAddons REQUIRED)
|
||||
find_package(KF6CoreAddons REQUIRED)
|
||||
find_package(KF6WidgetsAddons REQUIRED)
|
||||
endif()
|
||||
|
||||
set(KF_PRIVATE_LIBRARIES
|
||||
KF${KF_MAJOR_VERSION}::WidgetsAddons
|
||||
KF${KF_MAJOR_VERSION}::CoreAddons
|
||||
KF6::WidgetsAddons
|
||||
KF6::CoreAddons
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -35,5 +35,5 @@ FetchContent_Declare(
|
||||
SingleApplication
|
||||
GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication.git
|
||||
GIT_TAG v3.2.0)
|
||||
|
||||
set(QT_DEFAULT_MAJOR_VERSION 6)
|
||||
FetchContent_MakeAvailable(SingleApplication)
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
message(" - qet_compilation_vars")
|
||||
|
||||
# Note: GuiPrivate is intentionally NOT in this list. Qt6's CMake config only
|
||||
# creates the Qt::GuiPrivate target when "GuiPrivate" is explicitly requested
|
||||
# as a component, but Qt5 has no Qt5GuiPrivate package at all (the target is
|
||||
# created implicitly with Gui), so requesting it as a component breaks the
|
||||
# whole Qt5 configure. It is requested separately, guarded by
|
||||
# QT_VERSION_MAJOR, after the main find_package.
|
||||
# Note: GuiPrivate is intentionally NOT in this list.
|
||||
# Qt >= 6.7 ships it as a proper find_package component, but some distro
|
||||
# packages (e.g. Ubuntu's qt6-base-private-dev) omit Qt6GuiPrivateConfig.cmake
|
||||
# and only provide the implicit Qt6::GuiPrivate target created alongside
|
||||
# Qt6::Gui. Checks are done in the main CMakeLists.txt
|
||||
# (Needed for QPdfEngine::drawHyperlink, the PDF internal links.)
|
||||
set(QET_COMPONENTS
|
||||
LinguistTools
|
||||
@@ -841,15 +840,12 @@ if(NOT BUILD_WITH_KF)
|
||||
)
|
||||
endif()
|
||||
|
||||
# Qt6-only: PDF page import files
|
||||
if(QT_VERSION_MAJOR GREATER_EQUAL 6)
|
||||
list(APPEND QET_SRC_FILES
|
||||
list(APPEND QET_SRC_FILES
|
||||
${QET_DIR}/sources/diagramevent/diagrameventaddpdf.cpp
|
||||
${QET_DIR}/sources/diagramevent/diagrameventaddpdf.h
|
||||
${QET_DIR}/sources/ui/pdfpagesdialog.cpp
|
||||
${QET_DIR}/sources/ui/pdfpagesdialog.h
|
||||
)
|
||||
endif()
|
||||
)
|
||||
|
||||
# JavaScript scripting (bugtracker #162). Unconditionally in the source
|
||||
# list, like the QtPdf files above: this file is included before the
|
||||
|
||||
Reference in New Issue
Block a user