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>
This commit is contained in:
parent
a581f917e2
commit
2895f3ffaa
3
bin/qt-cmake.in
Executable file
3
bin/qt-cmake.in
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec @CMAKE_COMMAND@ -DCMAKE_TOOLCHAIN_FILE=@CMAKE_INSTALL_PREFIX@/@__GlobalConfig_install_dir@/qt.toolchain.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
|
||||
|
18
cmake/qt.toolchain.cmake.in
Normal file
18
cmake/qt.toolchain.cmake.in
Normal file
@ -0,0 +1,18 @@
|
||||
list(APPEND CMAKE_PREFIX_PATH "@CMAKE_INSTALL_PREFIX@")
|
||||
list(APPEND CMAKE_FIND_ROOT_PATH "@CMAKE_INSTALL_PREFIX@")
|
||||
|
||||
@init_qt_host_path@
|
||||
|
||||
@init_original_toolchain_file@
|
||||
|
||||
@init_vcpkg@
|
||||
|
||||
if(qt_chainload_toolchain_file)
|
||||
include("${qt_chainload_toolchain_file}")
|
||||
unset(qt_chainload_toolchain_file)
|
||||
endif()
|
||||
|
||||
if(QT_HOST_PATH)
|
||||
list(APPEND CMAKE_PREFIX_PATH "${QT_HOST_PATH}")
|
||||
list(APPEND CMAKE_FIND_ROOT_PATH "${QT_HOST_PATH}")
|
||||
endif()
|
Loading…
Reference in New Issue
Block a user