aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Giboudeaux <christophe@krop.fr>2022-03-26 10:44:17 +0100
committerChristophe Giboudeaux <christophe@krop.fr>2022-03-26 15:03:24 +0000
commit19311d26a6142cf6722d64834133664c68ac5865 (patch)
treec3cbdb63438a2397886e976a9b32c7b7287c7dbb
parent72c6f93248ff5057fb12b823daa8186f9f8f0b00 (diff)
downloadextra-cmake-modules-19311d26a6142cf6722d64834133664c68ac5865.tar.gz
extra-cmake-modules-19311d26a6142cf6722d64834133664c68ac5865.tar.bz2
ECMQueryQt: Add fallbacks
Some applications look for ECM and need to know Qt paths but don't need to link to anything. That's the case for icons or wallpapers. For these cases, ECMQueryQt will first try to find qmake or qtpaths before looking for Qt CMake config files. Also handle cases where project() sets 'LANGUAGE' to 'NONE'. The CXX language needs to be enabled for find_package to look for Qt into library dirs.
-rw-r--r--modules/ECMQueryQt.cmake20
1 files changed, 16 insertions, 4 deletions
diff --git a/modules/ECMQueryQt.cmake b/modules/ECMQueryQt.cmake
index 24dd42bc..f4e3bf7c 100644
--- a/modules/ECMQueryQt.cmake
+++ b/modules/ECMQueryQt.cmake
@@ -38,15 +38,27 @@ Since: 5.93
include(${CMAKE_CURRENT_LIST_DIR}/QtVersionOption.cmake)
if (QT_MAJOR_VERSION STREQUAL "5")
- find_package(Qt${QT_MAJOR_VERSION}Core QUIET)
- get_target_property(_qmake_executable_default Qt5::qmake LOCATION)
+ find_program(_qmake_executable_default NAMES qmake-qt5 qmake5)
+ if(NOT _qmake_executable_default)
+ # Enable the CXX language to let CMake look for config files
+ # into library dirs
+ enable_language(CXX)
+ find_package(Qt${QT_MAJOR_VERSION}Core QUIET)
+ if(TARGET Qt5::qmake)
+ get_target_property(_qmake_executable_default Qt5::qmake LOCATION)
+ endif()
+ endif()
set(QUERY_EXECUTABLE ${_qmake_executable_default}
CACHE FILEPATH "Location of the Qt5 qmake executable")
set(_exec_name_text "Qt5 qmake")
set(_cli_option "-query")
elseif(QT_MAJOR_VERSION STREQUAL "6")
- find_package(Qt6 COMPONENTS CoreTools REQUIRED CONFIG)
- get_target_property(_qtpaths_executable Qt6::qtpaths LOCATION)
+ find_program(_qtpaths_executable NAMES qtpaths6)
+ if(NOT _qtpaths_executable)
+ enable_language(CXX)
+ find_package(Qt6 COMPONENTS CoreTools REQUIRED CONFIG)
+ get_target_property(_qtpaths_executable Qt6::qtpaths LOCATION)
+ endif()
set(QUERY_EXECUTABLE ${_qtpaths_executable}
CACHE FILEPATH "Location of the Qt6 qtpaths executable")
set(_exec_name_text "Qt6 qtpaths")