summaryrefslogtreecommitdiffstats
path: root/cmake/QtBaseGlobalTargets.cmake
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2019-06-21 14:58:52 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2019-06-24 14:23:11 +0000
commit2895f3ffaa632f129232f70564a16f202ead0bda (patch)
tree4871a82cf1aa6f90542171bd4fec648fb714d9fb /cmake/QtBaseGlobalTargets.cmake
parenta581f917e2043828b032269dd6c8d60f338f3dba (diff)
Generate a toolchain and convenience cmake wrapper
This gets us a step into the direction of convenience that qmake offered: * QtBase is configured with a long command line (especially when cross-compiling) * Afterwards application developers (or other module builds) can just use qmake && make By generating a toolchain file we can capture vcpkg and toolchain chain-loading and a shell script can take care of providing the prefix path. Change-Id: Ided81f5432cab862306f2bea86cfe8e56adf71b0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtBaseGlobalTargets.cmake')
-rw-r--r--cmake/QtBaseGlobalTargets.cmake28
1 files changed, 28 insertions, 0 deletions
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index 5bb0925f5b..34f2cfe635 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -60,6 +60,34 @@ qt_install(FILES
COMPONENT Devel
)
+# Generate toolchain file for convenience
+if(QT_HOST_PATH)
+ get_filename_component(init_qt_host_path "${QT_HOST_PATH}" ABSOLUTE)
+ set(init_qt_host_path "set(QT_HOST_PATH \"${init_qt_host_path}\" CACHE PATH \"\" FORCE)")
+endif()
+
+if(CMAKE_TOOLCHAIN_FILE)
+ set(init_original_toolchain_file "set(qt_chainload_toolchain_file \"${CMAKE_TOOLCHAIN_FILE}\")")
+endif()
+
+if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
+ list(APPEND init_vcpkg "set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE \"${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}\")")
+endif()
+
+if(VCPKG_TARGET_TRIPLET)
+ list(APPEND init_vcpkg "set(VCPKG_TARGET_TRIPLET \"${VCPKG_TARGET_TRIPLET}\")")
+endif()
+
+string(REPLACE ";" "\n" init_vcpkg "${init_vcpkg}")
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/qt.toolchain.cmake.in" "${__GlobalConfig_build_dir}/qt.toolchain.cmake" @ONLY)
+qt_install(FILES "${__GlobalConfig_build_dir}/qt.toolchain.cmake" DESTINATION "${__GlobalConfig_install_dir}" COMPONENT Devel)
+
+# Also provide a convenience cmake wrapper
+if(UNIX)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bin/qt-cmake.in" "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake" @ONLY)
+ qt_install(PROGRAMS "${QT_BUILD_DIR}/bin/qt-cmake" DESTINATION "${INSTALL_BINDIR}")
+endif()
+
## Library to hold global features:
## These features are stored and accessed via Qt::GlobalConfig, but the
## files always lived in Qt::Core, so we keep it that way