Fix finding linguist tools macro when cross compiling with Qt 5

When cross compiling with Qt 5 the QT_HOST_PATH variable might
be set as well but the module might not be installed within the
host path. So let's do the usual lookup first and fallback to
QT_HOST_PATH only if that doesn't work.
This commit is contained in:
Martchus 2021-01-06 23:36:33 +01:00
parent 955b865e53
commit 5960c21558
1 changed files with 6 additions and 5 deletions

View File

@ -299,7 +299,8 @@ if (ENABLE_QT_TRANSLATIONS AND TS_FILES)
set(APP_SPECIFIC_QT_TRANSLATIONS_AVAILABLE YES)
# require the LinguistTools module (not adding it to QT_MODULES because we don't link against it)
if (QT_HOST_PATH)
find_package("${QT_LINGUIST_TOOLS_PACKAGE}")
if (NOT "${${QT_LINGUIST_TOOLS_PACKAGE}_FOUND}" AND QT_HOST_PATH)
# find the module within the host path when set (required for cross compilation with Qt 6 as the module is absent in
# the target install tree)
find_package(
@ -308,10 +309,10 @@ if (ENABLE_QT_TRANSLATIONS AND TS_FILES)
"${QT_HOST_PATH}"
"${QT_HOST_PATH}/lib/cmake"
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH
REQUIRED)
else ()
find_package("${QT_LINGUIST_TOOLS_PACKAGE}" REQUIRED)
NO_DEFAULT_PATH)
endif ()
if (NOT "${${QT_LINGUIST_TOOLS_PACKAGE}_FOUND}")
message(FATAL_ERROR "Qt translations are enabled but the CMake module \"${QT_LINGUIST_TOOLS_PACKAGE}\" could not be found.")
endif ()
if (NOT COMMAND qt_create_translation)