summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-10-12 11:29:43 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-10-12 13:36:03 +0200
commit0a0949837ec50b001595ad3f3eb032ed72d623ed (patch)
tree3e620aea6e84d6195e60ecf43a7e7a2604357d59
parentacf9b3a68b98b806329dd92184e632e049441cec (diff)
CMake: Allow customization of the generated CMake toolchain file
Provide two customization points: - optionally include a 'qt.toolchain.extra.cmake' file if it exists and is placed next to the main generated toolchain file. This use case is mostly for the Qt installer, so that it can create an extra file with correct installer-provided paths, instead of patching the toolchain file directly. - optionally include a file passed via the command line CMake argument 'QT_TOOLCHAIN_INCLUDE_FILE'. The use case is for application developers that might want to adjust the toolchain file after the modifications done by the Qt installer. These options do not replace the existing QT_CHAINLOAD_TOOLCHAIN_FILE option, which is meant to chainload a platform specific existing toolchain file (like Android or Emscripten). Task-number: QTBUG-87068 Change-Id: I956949840f55742cfbd3bc8fc0bd8c6b3f774d3d Reviewed-by: Cristian Adam <cristian.adam@qt.io>
-rw-r--r--cmake/qt.toolchain.cmake.in19
1 files changed, 19 insertions, 0 deletions
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in
index 1f8f90edb8..f1a7a5abaa 100644
--- a/cmake/qt.toolchain.cmake.in
+++ b/cmake/qt.toolchain.cmake.in
@@ -44,3 +44,22 @@ get_filename_component(QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR "${CMAKE_CURRENT_LIST_
list(PREPEND CMAKE_PREFIX_PATH "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR}")
list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX}")
@init_qt_host_path_checks@
+
+# Allow customization of the toolchain file by placing an additional file next to it.
+set(__qt_toolchain_extra_file "${CMAKE_CURRENT_LIST_DIR}/qt.toolchain.extra.cmake")
+if(EXISTS "${__qt_toolchain_extra_file}")
+ include("${__qt_toolchain_extra_file}")
+endif()
+
+# Allow customization of the toolchain file by passing a path to an additional CMake file to be
+# included.
+if(QT_TOOLCHAIN_INCLUDE_FILE)
+ get_filename_component(__qt_toolchain_include_file_real_path
+ "${QT_TOOLCHAIN_INCLUDE_FILE}" REALPATH)
+ if(EXISTS "${__qt_toolchain_include_file_real_path}")
+ include("${__qt_toolchain_include_file_real_path}")
+ else()
+ message(WARNING "The passed extra toolchain file to be included does not exist: "
+ "${__qt_toolchain_include_file_real_path}")
+ endif()
+endif()