aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-05-16 15:31:36 +0200
committerTobias Hunger <tobias.hunger@qt.io>2019-05-21 09:56:44 +0000
commit5da2b6edc731854408ccc94dcd9628d85daefcad (patch)
tree5edf725c7d95c8e7c0d413b8c507c10f3b2f1dbe /CMakeLists.txt
parent9d148276a31b4396a32fc049820b62842278ac45 (diff)
CMake: Get information from qmake
Get information that is not available via cmake from qmake. Change-Id: Ib80cd472bcb5ea831991de5fcbcb7e2400a1ce10 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt34
1 files changed, 34 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d323db81ae..d61df97c6c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,6 +54,40 @@ find_package(Qt5
REQUIRED
)
+# Get information on directories from qmake
+# as this is not yet exported by cmake.
+function(qt5_query_qmake)
+ if (NOT TARGET Qt5::qmake)
+ message(FATAL_ERROR "Qmake was not found.")
+ endif()
+
+ get_target_property(_qmake_binary Qt5::qmake IMPORTED_LOCATION)
+ execute_process(COMMAND "${_qmake_binary}" "-query"
+ TIMEOUT 10
+ RESULT_VARIABLE _qmake_result
+ OUTPUT_VARIABLE _qmake_stdout
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if (NOT "${_qmake_result}" STREQUAL "0")
+ message(FATAL_ERROR "Qmake did not execute successfully: ${_qmake_result}.")
+ endif()
+
+ # split into lines:
+ string(REPLACE "\n" ";" _lines "${_qmake_stdout}")
+
+ foreach(_line ${_lines})
+ # split line into key/value pairs
+ string(REPLACE ":" ";" _parts "${_line}")
+ list(GET _parts 0 _key)
+ list(REMOVE_AT _parts 0)
+ string(REPLACE ";" ":" _value "${_parts}")
+
+ set("${_key}" "${_value}" CACHE PATH "qmake import of ${_key}" FORCE)
+ endforeach()
+endfunction()
+
+qt5_query_qmake()
+
find_package(Qt5 COMPONENTS Designer Help SerialPort Svg QUIET)
function (set_if_target var target)
if (TARGET "${target}")