aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2022-04-15 19:54:34 +0000
committerChristophe Giboudeaux <christophe@krop.fr>2022-04-15 19:54:34 +0000
commit01f41fe327e66872a5182db1bbbace805e07df40 (patch)
tree30994d83330d1e0564e3a3b611140a5015586171
parent6224e7b8c28d434b81a19ac47b88cb58fee9d7d5 (diff)
downloadextra-cmake-modules-01f41fe327e66872a5182db1bbbace805e07df40.tar.gz
extra-cmake-modules-01f41fe327e66872a5182db1bbbace805e07df40.tar.bz2
ECMQueryQt: always use CMake target to find the qmake/qtpaths binary
This means removing the find_program() logic, since it was only useful if we don't want to make CMake spend time finding a compiler; so it was only useful for building modules that don't need a compiler at all, wallpapers, icon themes ...etc; so find_program() is only useful when it comes before the find_package() and enable_language() calls. Thanks to Christophe Giboudeaux for the explanation. This might make the build time for such modules a tiny bit longer, but it's worth it to make finding qmake/qtpaths
-rw-r--r--modules/ECMQueryQt.cmake49
1 files changed, 25 insertions, 24 deletions
diff --git a/modules/ECMQueryQt.cmake b/modules/ECMQueryQt.cmake
index 4f40ace7..98eb5008 100644
--- a/modules/ECMQueryQt.cmake
+++ b/modules/ECMQueryQt.cmake
@@ -36,35 +36,36 @@ Since: 5.93
#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/QtVersionOption.cmake)
+include(CheckLanguage)
+check_language(CXX)
+if (CMAKE_CXX_COMPILER)
+ # Enable the CXX language to let CMake look for config files in library dirs.
+ # See: https://gitlab.kitware.com/cmake/cmake/-/issues/23266
+ enable_language(CXX)
+endif()
if (QT_MAJOR_VERSION STREQUAL "5")
- find_program(_qmake_executable_default NAMES qmake 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()
+ # QUIET to accommodate the TRY option
+ find_package(Qt${QT_MAJOR_VERSION}Core QUIET)
+ if(TARGET Qt5::qmake)
+ get_target_property(_qmake_executable_default Qt5::qmake LOCATION)
+
+ set(QUERY_EXECUTABLE ${_qmake_executable_default}
+ CACHE FILEPATH "Location of the Qt5 qmake executable")
+ set(_exec_name_text "Qt5 qmake")
+ set(_cli_option "-query")
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_program(_qtpaths_executable NAMES qtpaths6)
- if(NOT _qtpaths_executable)
- enable_language(CXX)
- find_package(Qt6 COMPONENTS CoreTools QUIET CONFIG)
- if (TARGET Qt6::qtpaths)
- get_target_property(_qtpaths_executable Qt6::qtpaths LOCATION)
- endif()
+ # QUIET to accommodate the TRY option
+ find_package(Qt6 COMPONENTS CoreTools QUIET CONFIG)
+ if (TARGET Qt6::qtpaths)
+ get_target_property(_qtpaths_executable Qt6::qtpaths LOCATION)
+
+ set(QUERY_EXECUTABLE ${_qtpaths_executable}
+ CACHE FILEPATH "Location of the Qt6 qtpaths executable")
+ set(_exec_name_text "Qt6 qtpaths")
+ set(_cli_option "--query")
endif()
- set(QUERY_EXECUTABLE ${_qtpaths_executable}
- CACHE FILEPATH "Location of the Qt6 qtpaths executable")
- set(_exec_name_text "Qt6 qtpaths")
- set(_cli_option "--query")
endif()
function(ecm_query_qt result_variable qt_variable)