From 305e699a579814ec9111211bf279610ccf236f5d Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Wed, 20 Apr 2022 13:14:31 +0200 Subject: [PATCH] Adapt build system to building with Qt5 and Qt6 By default it builds with Qt5 (KDEInstallDirs module from ECM takes care of that), to build with Qt6 you need to build with -DQT_MAJOR_VERSION=6. --- CMakeLists.txt | 2 +- desktop/CMakeLists.txt | 14 +++++++++++--- src/CMakeLists.txt | 16 ++++++++-------- src/autotests/CMakeLists.txt | 4 ++-- src/characters/CMakeLists.txt | 2 +- src/session/CMakeLists.txt | 4 ++-- src/tests/CMakeLists.txt | 2 +- src/tests/demo_konsolepart/CMakeLists.txt | 2 +- src/tests/demo_konsolepart/src/CMakeLists.txt | 2 +- tools/uni2characterwidth/CMakeLists.txt | 4 ++-- 10 files changed, 30 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c0d975e..82ff527c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ endif() ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX KONSOLEPRIVATE SOVERSION 1 ) -find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED +find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED Core DBus PrintSupport diff --git a/desktop/CMakeLists.txt b/desktop/CMakeLists.txt index df6a9c43..2618a216 100644 --- a/desktop/CMakeLists.txt +++ b/desktop/CMakeLists.txt @@ -4,11 +4,19 @@ install( PROGRAMS org.kde.konsole.desktop DESTINATION ${KDE_INSTALL_APPDIR} ) install( FILES org.kde.konsole.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR} ) -install( FILES terminalemulator.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR} ) -install( FILES konsolepart.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) + +if(ECM_VERSION VERSION_GREATER_EQUAL "5.89.0") + install(FILES terminalemulator.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPESDIR}) + install(FILES konsolepart.desktop DESTINATION ${KDE_INSTALL_KSERVICESDIR}) + install(FILES konsole.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFYRCDIR}) +else() + install(FILES terminalemulator.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR}) + install(FILES konsolepart.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) + install(FILES konsole.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR}) +endif() + if(KF5KIO_VERSION VERSION_GREATER_EQUAL "5.85.0") install( PROGRAMS konsolerun.desktop DESTINATION ${KDE_INSTALL_DATADIR}/kio/servicemenus ) else() install( FILES konsolerun.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}/ServiceMenus ) endif() -install( FILES konsole.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR} ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b4a569c8..a7a521f1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,7 +21,7 @@ configure_file(config-konsole.h.cmake ### Tests if(BUILD_TESTING) - find_package(Qt5Test ${QT_MIN_VERSION} CONFIG REQUIRED) + find_package(Qt${QT_MAJOR_VERSION}Test ${QT_MIN_VERSION} CONFIG REQUIRED) add_subdirectory(autotests) add_subdirectory(tests) endif() @@ -40,9 +40,9 @@ option(KONSOLE_BUILD_UNI2CHARACTERWIDTH "Konsole: build uni2characterwidth execu # qdbuscpp2xml -M -s ViewManager.h -o org.kde.konsole.Konsole.xml # Generate dbus .xml files; do not store .xml in source folder -qt5_generate_dbus_interface(ViewManager.h org.kde.konsole.Window.xml OPTIONS -m) +qt_generate_dbus_interface(ViewManager.h org.kde.konsole.Window.xml OPTIONS -m) -qt5_add_dbus_adaptor(windowadaptors_SRCS +qt_add_dbus_adaptor(windowadaptors_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.konsole.Window.xml ViewManager.h Konsole::ViewManager) @@ -50,8 +50,8 @@ qt5_add_dbus_adaptor(windowadaptors_SRCS set(konsole_LIBS KF5::XmlGui - Qt5::PrintSupport - Qt5::Xml + Qt::PrintSupport + Qt::Xml KF5::Notifications KF5::WindowSystem KF5::TextWidgets @@ -99,8 +99,8 @@ add_library(konsolehelpers ${konsolehelpers_SRCS} ) target_link_libraries(konsolehelpers - Qt5::Core - Qt5::Widgets + Qt::Core + Qt::Widgets ) add_subdirectory(colorscheme) @@ -225,7 +225,7 @@ ki18n_wrap_ui(konsoleprivate_SRCS ) # add the resource files for the ui files -qt5_add_resources( konsoleprivate_SRCS ../desktop/konsole.qrc) +qt_add_resources( konsoleprivate_SRCS ../desktop/konsole.qrc) add_library(konsoleprivate ${konsoleprivate_SRCS}) generate_export_header(konsoleprivate BASE_NAME konsoleprivate) diff --git a/src/autotests/CMakeLists.txt b/src/autotests/CMakeLists.txt index f1ac634b..75ea6df2 100644 --- a/src/autotests/CMakeLists.txt +++ b/src/autotests/CMakeLists.txt @@ -3,7 +3,7 @@ include(ECMMarkNonGuiExecutable) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) -set(KONSOLE_TEST_LIBS Qt5::Test konsoleprivate) +set(KONSOLE_TEST_LIBS Qt::Test konsoleprivate) add_executable(BookMarkTest BookMarkTest.cpp) ecm_mark_as_test(BookMarkTest) @@ -44,7 +44,7 @@ else() ecm_mark_as_test(DBusTest) ecm_mark_nongui_executable(DBusTest) add_test(NAME DBusTest COMMAND DBusTest) - target_link_libraries(DBusTest ${KONSOLE_TEST_LIBS} Qt5::DBus) + target_link_libraries(DBusTest ${KONSOLE_TEST_LIBS} Qt::DBus) endif() endif() diff --git a/src/characters/CMakeLists.txt b/src/characters/CMakeLists.txt index 7468fc7b..bc84a8f3 100644 --- a/src/characters/CMakeLists.txt +++ b/src/characters/CMakeLists.txt @@ -21,4 +21,4 @@ generate_export_header(konsolecharacters BASE_NAME konsolecharacters) target_include_directories(konsolecharacters PUBLIC ${CMAKE_CURRENT_BINARY_DIR} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(konsolecharacters Qt5::Gui) +target_link_libraries(konsolecharacters Qt::Gui) diff --git a/src/session/CMakeLists.txt b/src/session/CMakeLists.txt index e369da19..e6bb6ec1 100644 --- a/src/session/CMakeLists.txt +++ b/src/session/CMakeLists.txt @@ -5,9 +5,9 @@ # qdbuscpp2xml -m Session.h -o org.kde.konsole.Session.xml # Generate dbus .xml files; do not store .xml in source folder -qt5_generate_dbus_interface(Session.h org.kde.konsole.Session.xml OPTIONS -m) +qt_generate_dbus_interface(Session.h org.kde.konsole.Session.xml OPTIONS -m) -qt5_add_dbus_adaptor( +qt_add_dbus_adaptor( sessionadaptors_SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.konsole.Session.xml Session.h diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index af46d54f..36dd93a1 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -4,7 +4,7 @@ include(ECMMarkAsTest) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) -set(KONSOLE_TEST_LIBS Qt5::Test konsoleprivate) +set(KONSOLE_TEST_LIBS Qt::Test konsoleprivate) add_executable(PartManualTest PartManualTest.cpp) ecm_mark_as_test(PartManualTest) diff --git a/src/tests/demo_konsolepart/CMakeLists.txt b/src/tests/demo_konsolepart/CMakeLists.txt index aa111bb2..cf5c703c 100644 --- a/src/tests/demo_konsolepart/CMakeLists.txt +++ b/src/tests/demo_konsolepart/CMakeLists.txt @@ -13,7 +13,7 @@ include(ECMInstallIcons) include(FeatureSummary) set(QT_MIN_VERSION "5.4.0") -find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets) +find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets) set(REQUIRED_KF5_VERSION "5.18.0") find_package(KF5 ${REQUIRED_KF5_VERSION} REQUIRED COMPONENTS diff --git a/src/tests/demo_konsolepart/src/CMakeLists.txt b/src/tests/demo_konsolepart/src/CMakeLists.txt index 4e61708c..5635e4af 100644 --- a/src/tests/demo_konsolepart/src/CMakeLists.txt +++ b/src/tests/demo_konsolepart/src/CMakeLists.txt @@ -10,7 +10,7 @@ target_link_libraries(demo_konsolepart KF5::I18n KF5::Parts KF5::Pty - Qt5::Widgets + Qt::Widgets KF5::XmlGui KF5::WindowSystem ) diff --git a/tools/uni2characterwidth/CMakeLists.txt b/tools/uni2characterwidth/CMakeLists.txt index e1af4121..7a4dbb0f 100644 --- a/tools/uni2characterwidth/CMakeLists.txt +++ b/tools/uni2characterwidth/CMakeLists.txt @@ -7,7 +7,7 @@ ### See `uni2characterwidth --help` for usage information if(KONSOLE_BUILD_UNI2CHARACTERWIDTH) - find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED + find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED Core ) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED @@ -23,7 +23,7 @@ if(KONSOLE_BUILD_UNI2CHARACTERWIDTH) add_executable(uni2characterwidth ${uni2characterwidth_SRC}) target_link_libraries(uni2characterwidth - Qt5::Core + Qt::Core KF5::KIOCore )