Skip to content

Commit 780de63

Browse files
committed
[WIP] Add Qt6 compat to asteroidapp
1 parent 8a66d37 commit 780de63

File tree

6 files changed

+94
-10
lines changed

6 files changed

+94
-10
lines changed

cmake/AsteroidTranslations.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ function(BUILD_TRANSLATIONS directory)
44
return()
55
endif()
66

7-
find_package(Qt5LinguistTools REQUIRED)
7+
find_package(Qt${QT_MAJOR_VERSION} COMPONENTS LinguistTools REQUIRED)
88

99
file(GLOB LANGUAGE_FILES_TS ${directory}/*.ts)
1010
#set_source_files_properties(${LANGUAGE_FILES_TS} PROPERTIES OUTPUT_LOCATION "i18n")
11-
qt5_add_translation(LANGUAGE_FILES_QM ${LANGUAGE_FILES_TS} OPTIONS "-idbased")
11+
# FIXME: has to be qt5_add_translation alternatively?
12+
qt_add_translation(LANGUAGE_FILES_QM ${LANGUAGE_FILES_TS} OPTIONS "-idbased")
1213
add_custom_target(build-translations ALL
1314
COMMENT "Building translations in ${director}..."
1415
DEPENDS ${LANGUAGE_FILES_QM})

cmake/FindMapplauncherd_qt6.cmake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Try to find qdeclarative6-boostable
2+
# Once done this will define
3+
# MAPPLAUNCHERD_QT6_FOUND - System has qdeclarative
4+
# MAPPLAUNCHERD_QT6_INCLUDE_DIRS - The qdeclarative include directories
5+
# MAPPLAUNCHERD_QT6_LIBRARIES - The libraries needed to use qdeclarative
6+
# MAPPLAUNCHERD_QT6_DEFINITIONS - Compiler switches required for using qdeclarative
7+
8+
find_package(PkgConfig REQUIRED)
9+
pkg_check_modules(PC_Mapplauncherd_qt6 QUIET qdeclarative6-boostable)
10+
set(Mapplauncherd_qt6_DEFINITIONS ${PC_Mapplauncherd_qt6_CFLAGS_OTHER})
11+
12+
find_path(Mapplauncherd_qt6_INCLUDE_DIRS
13+
NAMES mdeclarativecache.h
14+
PATH_SUFFIXES mdeclarativecache6
15+
PATHS ${PC_Mapplauncherd_qt6_INCLUDEDIR} ${PC_Mapplauncherd_qt6_INCLUDE_DIRS})
16+
17+
find_library(Mapplauncherd_qt6_LIBRARIES
18+
NAMES mdeclarativecache6
19+
PATHS ${PC_Mapplauncherd_qt6_LIBDIR} ${PC_Mapplauncherd_qt6_LIBRARY_DIRS})
20+
21+
set(Mapplauncherd_qt6_VERSION ${PC_Mapplauncherd_qt6_VERSION})
22+
23+
include(FindPackageHandleStandardArgs)
24+
find_package_handle_standard_args(Mapplauncherd_qt6
25+
FOUND_VAR
26+
Mapplauncherd_qt6_FOUND
27+
REQUIRED_VARS
28+
Mapplauncherd_qt6_LIBRARIES
29+
Mapplauncherd_qt6_INCLUDE_DIRS
30+
VERSION_VAR
31+
Mapplauncherd_qt6_VERSION)
32+
33+
mark_as_advanced(Mapplauncherd_qt6_INCLUDE_DIR Mapplauncherd_qt6_LIBRARY Mapplauncherd_qt6_VERSION)
34+
35+
if(Mapplauncherd_qt6_FOUND AND NOT TARGET Mapplauncherd_qt6::Mapplauncherd_qt6)
36+
add_library(Mapplauncherd_qt6::Mapplauncherd_qt6 UNKNOWN IMPORTED)
37+
set_target_properties(Mapplauncherd_qt6::Mapplauncherd_qt6 PROPERTIES
38+
IMPORTED_LOCATION "${Mapplauncherd_qt6_LIBRARIES}"
39+
INTERFACE_INCLUDE_DIRECTORIES "${Mapplauncherd_qt6_INCLUDE_DIRS}")
40+
endif()

cmake/FindMlite6.cmake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Try to find mlite6
2+
# Once done this will define
3+
# MLITE6_FOUND - System has mlite6
4+
# MLITE6_INCLUDE_DIRS - The mlite6 include directories
5+
# MLITE6_LIBRARIES - The libraries needed to use mlite6
6+
# MLITE6_DEFINITIONS - Compiler switches required for using mlite6
7+
8+
find_package(PkgConfig REQUIRED)
9+
pkg_check_modules(PC_Mlite6 QUIET mlite6)
10+
set(Mlite6_DEFINITIONS ${PC_Mlite6_CFLAGS_OTHER})
11+
12+
find_path(Mlite6_INCLUDE_DIRS
13+
NAMES mlite-global.h
14+
PATH_SUFFIXES mlite6
15+
PATHS ${PC_Mlite6_INCLUDEDIR} ${PC_Mlite6_INCLUDE_DIRS})
16+
17+
find_library(Mlite6_LIBRARIES
18+
NAMES mlite6
19+
PATHS ${PC_Mlite6_LIBDIR} ${PC_Mlite6_LIBRARY_DIRS})
20+
21+
set(Mlite6_VERSION ${PC_Mlite6_VERSION})
22+
23+
include(FindPackageHandleStandardArgs)
24+
find_package_handle_standard_args(Mlite6
25+
FOUND_VAR
26+
Mlite6_FOUND
27+
REQUIRED_VARS
28+
Mlite6_LIBRARIES
29+
Mlite6_INCLUDE_DIRS
30+
VERSION_VAR
31+
Mlite6_VERSION)
32+
33+
mark_as_advanced(Mlite6_INCLUDE_DIR Mlite6_LIBRARY Mlite6_VERSION)
34+
35+
if(Mlite6_FOUND AND NOT TARGET Mlite6::Mlite6)
36+
add_library(Mlite6::Mlite6 UNKNOWN IMPORTED)
37+
set_target_properties(Mlite6::Mlite6 PROPERTIES
38+
IMPORTED_LOCATION "${Mlite6_LIBRARIES}"
39+
INTERFACE_INCLUDE_DIRECTORIES "${Mlite6_INCLUDE_DIRS}")
40+
endif()

src/app/AsteroidAppConfig.cmake.in

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
@PACKAGE_INIT@
22

33
include(CMakeFindDependencyMacro)
4-
find_dependency(Qt5Qml @QT_MIN_VERSION@)
5-
find_dependency(Qt5Quick @QT_MIN_VERSION@)
4+
# TODO: wasn't there a better way especially with 5.15/6 like find_package(Qt COMPONENTS Core REQUIRED)
5+
if (NOT DEFINED QT_MAJOR_VERSION)
6+
set(QT_MAJOR_VERSION 5)
7+
endif()
8+
find_package(Qt${QT_MAJOR_VERSION} @QT_MIN_VERSION@ COMPONENTS Qml Quick REQUIRED)
69

710
set(ASTEROID_MODULE_PATH "@PACKAGE_ASTEROID_MODULES_INSTALL_DIR@")
811

src/app/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ add_library(asteroidapp ${SRC} ${HEADERS})
55

66
target_link_libraries(asteroidapp
77
PUBLIC
8-
Qt5::Qml
9-
Qt5::Quick
8+
Qt::Qml
9+
Qt::Quick
1010
PRIVATE
11-
Mlite5::Mlite5
12-
Mapplauncherd_qt5::Mapplauncherd_qt5)
11+
Mlite${QT_MAJOR_VERSION}::Mlite${QT_MAJOR_VERSION}
12+
Mapplauncherd_qt${QT_MAJOR_VERSION}::Mapplauncherd_qt${QT_MAJOR_VERSION})
1313

1414
set_target_properties(asteroidapp PROPERTIES
1515
EXPORT_NAME AsteroidApp
@@ -36,7 +36,7 @@ install(FILES asteroidapp.prf
3636

3737
ecm_generate_pkgconfig_file(
3838
BASE_NAME asteroidapp
39-
DEPS qdeclarative5-boostable
39+
DEPS qdeclarative${QT_MAJOR_VERSION}-boostable
4040
FILENAME_VAR asteroidapp
4141
DESCRIPTION ${PROJECT_DESCRIPTION}
4242
INSTALL)

src/app/asteroidapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <QFileInfo>
3434
#include <MDesktopEntry>
3535
#include <QTranslator>
36-
#include <mdeclarativecache5/MDeclarativeCache>
36+
#include <mdeclarativecache/MDeclarativeCache>
3737

3838
static QString applicationPath()
3939
{

0 commit comments

Comments
 (0)