@@ -13,42 +13,52 @@ option(enable-glib "Build GLib support" ON)
1313
1414option (enable-xcb "Compile with xcb support" ON )
1515option (enable-wayland "Compile with support for wayland" ON )
16- option (enable-qt5 -inputcontext "Compile with Qt 5 input context" ON )
16+ option (enable-qt -inputcontext "Compile with Qt input context" ON )
1717
1818option (enable-hwkeyboard "Enable support for the hardware keyboard" ON )
1919option (enable-dbus-activation "Enable dbus activation support for maliit-server" OFF )
20+ option (with-qt6 "Built with Qt 6 instead of Qt 5" OFF )
2021
2122# Install paths
2223include (GNUInstallDirs )
2324
24- if (NOT DEFINED QT5_PLUGINS_INSTALL_DIR)
25- set (QT5_PLUGINS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR} /qt5/plugins" CACHE PATH
26- "Installation directory for Qt 5 plugins [LIB_INSTALL_DIR/qt5/plugins]" )
27- endif ()
28-
29- if (NOT DEFINED QT5_MKSPECS_INSTALL_DIR)
30- set (QT5_MKSPECS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR} /qt5/mkspecs" CACHE PATH
31- "Installation directory for Qt 5 mkspecs files [LIB_INSTALL_DIR/qt5/mkspecs]" )
32- endif ()
33-
3425list (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR} /cmake" )
3526
3627set (CMAKE_INCLUDE_CURRENT_DIR ON )
3728set (CMAKE_AUTOMOC ON )
3829
3930find_package (PkgConfig REQUIRED )
4031
41- find_package (Qt5Core )
42- find_package (Qt5DBus )
43- find_package (Qt5Gui REQUIRED PRIVATE )
44- find_package (Qt5Quick )
32+ if (with-qt6)
33+ find_package (Qt6 6.0 REQUIRED COMPONENTS Core DBus Gui Quick )
34+ endif ()
35+
36+ if (Qt6_FOUND)
37+ set (QT_VERSION_MAJOR 6)
38+ else ()
39+ find_package (Qt5 REQUIRED COMPONENTS Core DBus Gui Quick )
40+ set (QT_VERSION_MAJOR 5)
41+ endif ()
42+
43+ if (NOT DEFINED QT_PLUGINS_INSTALL_DIR)
44+ set (QT_PLUGINS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR} /qt${QT_VERSION_MAJOR} /plugins" CACHE PATH
45+ "Installation directory for Qt ${QT_VERSION_MAJOR} plugins [LIB_INSTALL_DIR/qt${QT_VERSION_MAJOR} /plugins]" )
46+ endif ()
47+
48+ if (NOT DEFINED QT_MKSPECS_INSTALL_DIR)
49+ set (QT_MKSPECS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR} /qt${QT_VERSION_MAJOR} /mkspecs" CACHE PATH
50+ "Installation directory for Qt 5 mkspecs files [LIB_INSTALL_DIR/qt${QT_VERSION_MAJOR} /mkspecs]" )
51+ endif ()
4552
4653if (enable-wayland)
54+ if (Qt6_FOUND)
55+ find_package (Qt6 REQUIRED COMPONENTS WaylandClient WaylandGlobalPrivate )
56+ else ()
57+ find_package (Qt5 5.14 REQUIRED COMPONENTS WaylandClient XkbCommonSupport )
58+ endif ()
4759 find_package (WaylandProtocols REQUIRED PRIVATE )
4860 find_package (QtWaylandScanner REQUIRED )
4961 find_package (Wayland REQUIRED )
50- find_package (Qt5WaylandClient 5.14 REQUIRED PRIVATE )
51- find_package (Qt5XkbCommonSupport REQUIRED PRIVATE )
5262 pkg_check_modules (XKBCOMMON REQUIRED IMPORTED_TARGET xkbcommon )
5363endif ()
5464
@@ -59,7 +69,7 @@ add_library(maliit-common STATIC
5969 common/maliit/namespaceinternal.h
6070 common/maliit/settingdata.cpp
6171 common/maliit/settingdata.h )
62- target_link_libraries (maliit-common Qt5 ::Core )
72+ target_link_libraries (maliit-common Qt${QT_VERSION_MAJOR} ::Core )
6373target_include_directories (maliit-common PUBLIC common )
6474
6575set (CONNECTION_SOURCES
@@ -94,21 +104,33 @@ endif()
94104set_source_files_properties (dbus_interfaces/minputmethodcontext1interface.xml dbus_interfaces/minputmethodserver1interface.xml
95105 PROPERTIES INCLUDE maliit/settingdata.h )
96106
107+ if (Qt6_FOUND)
108+ qt6_add_dbus_adaptor (CONNECTION_SOURCES dbus_interfaces/minputmethodcontext1interface.xml dbusserverconnection.h DBusServerConnection )
109+ qt6_add_dbus_adaptor (CONNECTION_SOURCES dbus_interfaces/minputmethodserver1interface.xml dbusinputcontextconnection.h DBusInputContextConnection )
110+
111+ qt6_add_dbus_interface (CONNECTION_SOURCES dbus_interfaces/minputmethodcontext1interface.xml minputmethodcontext1interface_interface )
112+ qt6_add_dbus_interface (CONNECTION_SOURCES dbus_interfaces/minputmethodserver1interface.xml minputmethodserver1interface_interface )
113+ else ()
97114qt5_add_dbus_adaptor (CONNECTION_SOURCES dbus_interfaces/minputmethodcontext1interface.xml dbusserverconnection.h DBusServerConnection )
98115qt5_add_dbus_adaptor (CONNECTION_SOURCES dbus_interfaces/minputmethodserver1interface.xml dbusinputcontextconnection.h DBusInputContextConnection )
99116
100117qt5_add_dbus_interface (CONNECTION_SOURCES dbus_interfaces/minputmethodcontext1interface.xml minputmethodcontext1interface_interface )
101118qt5_add_dbus_interface (CONNECTION_SOURCES dbus_interfaces/minputmethodserver1interface.xml minputmethodserver1interface_interface )
119+ endif ()
102120
103121add_library (maliit-connection STATIC ${CONNECTION_SOURCES} )
104- target_link_libraries (maliit-connection Qt5 ::Core Qt5 ::DBus Qt5 ::Gui maliit-common )
122+ target_link_libraries (maliit-connection Qt ::Core Qt ::DBus Qt ::Gui maliit-common )
105123if (enable-wayland)
106124 target_link_libraries (maliit-connection Wayland::Client PkgConfig::XKBCOMMON )
107- target_include_directories (maliit-connection PRIVATE ${Qt5WaylandClient_PRIVATE_INCLUDE_DIRS} )
125+ if (Qt6_FOUND)
126+ target_include_directories (maliit-connection PRIVATE ${Qt6Gui_PRIVATE_INCLUDE_DIRS} )
127+ else ()
128+ target_include_directories (maliit-connection PRIVATE ${Qt5Gui_PRIVATE_INCLUDE_DIRS} )
129+ endif ()
108130endif ()
109131target_include_directories (maliit-connection PUBLIC connection )
110132
111- include_directories (${Qt5Gui_PRIVATE_INCLUDE_DIRS } )
133+ include_directories (${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS } )
112134
113135set (PLUGINS_SOURCES
114136 src/maliit/plugins/abstractinputmethod.cpp
@@ -213,7 +235,7 @@ endif()
213235
214236add_library (maliit-plugins SHARED ${PLUGINS_SOURCES} ${PLUGINS_HEADER} )
215237target_link_libraries (maliit-plugins PRIVATE maliit-common maliit-connection ${PLUGINS_LIBRARIES} )
216- target_link_libraries (maliit-plugins PUBLIC Qt5 ::Core Qt5 ::Gui Qt5 ::Quick )
238+ target_link_libraries (maliit-plugins PUBLIC Qt${QT_VERSION_MAJOR} ::Core Qt${QT_VERSION_MAJOR} ::Gui Qt${QT_VERSION_MAJOR} ::Quick )
217239target_include_directories (maliit-plugins PRIVATE ${PLUGINS_INCLUDE_DIRS} )
218240
219241set_target_properties (maliit-plugins PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}
@@ -288,14 +310,14 @@ add_definitions(-DMALIIT_FRAMEWORK_USE_INTERNAL_API
288310add_executable (maliit-server passthroughserver/main.cpp )
289311target_link_libraries (maliit-server maliit-plugins maliit-connection )
290312
291- if (enable-qt5 -inputcontext)
313+ if (enable-qt -inputcontext)
292314 set (INPUT_CONTEXT_SOURCES
293315 input-context/main.cpp
294316 input-context/minputcontext.cpp
295317 input-context/minputcontext.h)
296318
297319 add_library (maliitplatforminputcontextplugin MODULE ${INPUT_CONTEXT_SOURCES} )
298- target_link_libraries (maliitplatforminputcontextplugin maliit-connection Qt5 ::Quick )
320+ target_link_libraries (maliitplatforminputcontextplugin maliit-connection Qt${QT_VERSION_MAJOR} ::Quick )
299321endif ()
300322
301323if (enable-wayland)
@@ -307,31 +329,36 @@ if(enable-wayland)
307329 ecm_add_qtwayland_client_protocol (INPUT_PANEL_SHELL_SOURCES PROTOCOL ${WAYLANDPROTOCOLS_PATH} /unstable/input-method/input-method-unstable-v1.xml BASENAME input -method-unstable-v1 )
308330
309331 add_library (inputpanel-shell MODULE ${INPUT_PANEL_SHELL_SOURCES} )
310- target_link_libraries (inputpanel-shell Qt5::WaylandClient PkgConfig::XKBCOMMON Wayland::Client )
311- target_include_directories (inputpanel-shell PRIVATE ${Qt5WaylandClient_PRIVATE_INCLUDE_DIRS} ${Qt5XkbCommonSupport_PRIVATE_INCLUDE_DIRS} )
332+ target_link_libraries (inputpanel-shell Qt::WaylandClient PkgConfig::XKBCOMMON Wayland::Client )
333+ if (Qt6_FOUND)
334+ target_link_libraries (inputpanel-shell Qt::WaylandGlobalPrivate )
335+ target_include_directories (inputpanel-shell PRIVATE ${Qt6WaylandClient_PRIVATE_INCLUDE_DIRS} ${Qt6WaylandGlobalPrivate_PRIVATE_INCLUDE_DIRS} ${Qt6XkbCommonSupport_PRIVATE_INCLUDE_DIRS} )
336+ else ()
337+ target_include_directories (inputpanel-shell PRIVATE ${Qt5WaylandClient_PRIVATE_INCLUDE_DIRS} ${Qt5XkbCommonSupport_PRIVATE_INCLUDE_DIRS} )
338+ endif ()
312339endif ()
313340
314341if (enable-examples)
315- find_package (Qt5Widgets )
342+ find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets )
316343 add_executable (maliit-exampleapp-plainqt
317344 examples/apps/plainqt/mainwindow.cpp
318345 examples/apps/plainqt/mainwindow.h
319346 examples/apps/plainqt/plainqt.cpp )
320- target_link_libraries (maliit-exampleapp-plainqt Qt5 ::Gui Qt5 ::Widgets )
347+ target_link_libraries (maliit-exampleapp-plainqt Qt ::Gui Qt ::Widgets )
321348
322349 add_library (cxxhelloworldplugin MODULE
323350 examples/plugins/cxx/helloworld/helloworldinputmethod.cpp
324351 examples/plugins/cxx/helloworld/helloworldinputmethod.h
325352 examples/plugins/cxx/helloworld/helloworldplugin.cpp
326353 examples/plugins/cxx/helloworld/helloworldplugin.h )
327- target_link_libraries (cxxhelloworldplugin maliit-plugins Qt5 ::Widgets )
354+ target_link_libraries (cxxhelloworldplugin maliit-plugins Qt ::Widgets )
328355
329356 add_library (cxxoverrideplugin MODULE
330357 examples/plugins/cxx/override/overrideinputmethod.cpp
331358 examples/plugins/cxx/override/overrideinputmethod.h
332359 examples/plugins/cxx/override/overrideplugin.cpp
333360 examples/plugins/cxx/override/overrideplugin.h )
334- target_link_libraries (cxxoverrideplugin maliit-plugins Qt5 ::Widgets )
361+ target_link_libraries (cxxoverrideplugin maliit-plugins Qt ::Widgets )
335362endif ()
336363
337364# Documentation
@@ -395,7 +422,7 @@ install(FILES src/mimserver.h
395422install (FILES ${CMAKE_BINARY_DIR} /maliit-framework .pc ${CMAKE_BINARY_DIR} /maliit-plugins.pc ${CMAKE_BINARY_DIR} /maliit-server.pc
396423 DESTINATION ${CMAKE_INSTALL_LIBDIR} /pkgconfig)
397424install (FILES ${CMAKE_BINARY_DIR} /maliit-framework .prf ${CMAKE_BINARY_DIR} /maliit-plugins.prf ${CMAKE_BINARY_DIR} /maliit-defines.prf
398- DESTINATION ${QT5_MKSPECS_INSTALL_DIR } /features)
425+ DESTINATION ${QT_MKSPECS_INSTALL_DIR } /features)
399426
400427install (EXPORT MaliitPluginsTargets FILE MaliitPluginsTargets.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/MaliitPlugins)
401428install (FILES ${CMAKE_CURRENT_BINARY_DIR} /MaliitPluginsConfig.cmake ${CMAKE_CURRENT_BINARY_DIR} /MaliitPluginsConfigVersion.cmake
@@ -432,12 +459,12 @@ if(enable-glib)
432459endif ()
433460
434461if (enable-qt5-inputcontext)
435- install (TARGETS maliitplatforminputcontextplugin LIBRARY DESTINATION ${QT5_PLUGINS_INSTALL_DIR } /platforminputcontexts)
462+ install (TARGETS maliitplatforminputcontextplugin LIBRARY DESTINATION ${QT_PLUGINS_INSTALL_DIR } /platforminputcontexts)
436463endif ()
437464
438465if (enable-wayland)
439466 install (TARGETS inputpanel-shell
440- LIBRARY DESTINATION ${QT5_PLUGINS_INSTALL_DIR } /wayland-shell-integration)
467+ LIBRARY DESTINATION ${QT_PLUGINS_INSTALL_DIR } /wayland-shell-integration)
441468endif ()
442469
443470if (enable-dbus-activation)
@@ -456,7 +483,7 @@ endif()
456483if (enable-tests)
457484 enable_testing ()
458485
459- find_package (Qt5Test )
486+ find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test )
460487
461488 set (TEST_PLUGINS_DIR ${CMAKE_BINARY_DIR} /tests/plugins)
462489
@@ -497,7 +524,7 @@ if(enable-tests)
497524 tests/utils/core-utils.h
498525 tests/utils/gui-utils.cpp
499526 tests/utils/gui-utils.h )
500- target_link_libraries (test -utils PUBLIC Qt5 ::Core Qt5 ::Gui Qt5 ::Test maliit-connection )
527+ target_link_libraries (test -utils PUBLIC Qt ::Core Qt ::Gui Qt ::Test maliit-connection )
501528 target_include_directories (test -utils INTERFACE tests/utils )
502529 target_compile_definitions (test -utils PUBLIC
503530 -DMALIIT_TEST_PLUGINS_DIR= "${CMAKE_INSTALL_FULL_LIBDIR} /maliit-framework-tests/plugins"
@@ -508,7 +535,7 @@ if(enable-tests)
508535 tests/stubs/mkeyboardstatetracker_stub.h
509536 tests/stubs/fakeproperty.cpp
510537 tests/stubs/fakeproperty.h )
511- target_link_libraries (test -stubs PUBLIC Qt5 ::Core )
538+ target_link_libraries (test -stubs PUBLIC Qt ::Core )
512539 target_include_directories (test -stubs INTERFACE tests/stubs )
513540
514541 function (create_test name )
0 commit comments