CMake: Introduce qt-configure-module

Add a convenience script to configure a Qt module separately.
This script reads and interprets the qt_cmdline.cmake files of the
Qt module to be configured and eventually calls qt-cmake-private.

Example usage:
<install-prefix>/bin/qt-configure-module <source-root>/qtdeclarative
  -qml-network -- --trace-expand --trace-redirect=cmake.trace

Change-Id: I026f1a050cd3f4df740611c32ba8c03161bba7a3
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Joerg Bornemann 2020-08-31 10:38:53 +02:00
parent c30ea1f412
commit 457cf10f7e
3 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,38 @@
@echo off
setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
set script_dir_path=%~dp0
set script_dir_path=%script_dir_path:~0,-1%
if "%1" == "" (
call :print_usage
exit /b 1
)
set module_root=%1
shift
if not exist "%module_root%\CMakeLists.txt" (
echo Error: %module_root% is not a valid Qt module source directory. >&2
call :print_usage
exit /b 1
)
if exist "config.opt" del "config.opt"
set first_iteration=indeed
for %%a in (%*) do (
if defined first_iteration (
:: Drop the first argument, which is the module root.
set first_iteration=
) else (
echo %%a >> "config.opt"
)
)
set cmake_script_path=%script_dir_path%\@__relative_path_to_processconfigureargs_script@
call "%script_dir_path%"\qt-cmake-private.bat -DOPTFILE=config.opt -DMODULE_ROOT="%module_root%" ^
-DCMAKE_COMMAND="%script_dir_path%\qt-cmake-private.bat" ^
-P "%cmake_script_path%"
goto :eof
:print_usage
echo Usage: qt-configure-module ^<module-source-dir^> [options]
goto :eof

30
bin/qt-configure-module.in Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
script_dir_path=`dirname $0`
script_dir_path=`(cd "$script_dir_path"; /bin/pwd)`
printUsage()
{
echo 'Usage: qt-configure-module <module-source-dir> [options]'
}
if [ "$#" -lt 1 ]; then
printUsage
exit 1
fi
module_root=$1
shift
if [ ! -f "$module_root/CMakeLists.txt" ]; then
echo >&2 "Error: $module_root is not a valid Qt module source directory."
printUsage
exit 1
fi
optfile=config.opt
if [ -f "$optfile" ]; then rm "$optfile"; fi
for arg in "$@"; do
echo $arg >> "$optfile"
done
cmake_script_path="$script_dir_path/@__relative_path_to_processconfigureargs_script@"
"$script_dir_path/qt-cmake-private" -DOPTFILE=$optfile -DMODULE_ROOT="$module_root" -DCMAKE_COMMAND="$script_dir_path/qt-cmake-private" -P "$cmake_script_path"

View File

@ -239,6 +239,30 @@ qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake-private.bat" DES
endif()
unset(__qt_cmake_extra)
# Provide a script to configure Qt modules.
if(QT_WILL_INSTALL)
set(__relative_path_to_processconfigureargs_script
"${__GlobalConfig_relative_path_from_bin_dir_to_cmake_config_dir}")
else()
file(RELATIVE_PATH __relative_path_to_processconfigureargs_script
"${__qt_bin_dir_absolute}" "${CMAKE_CURRENT_LIST_DIR}")
endif()
string(APPEND __relative_path_to_processconfigureargs_script "/QtProcessConfigureArgs.cmake")
file(TO_NATIVE_PATH "${__relative_path_to_processconfigureargs_script}"
__relative_path_to_processconfigureargs_script)
if(CMAKE_HOST_UNIX)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bin/qt-configure-module.in"
"${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-configure-module" @ONLY)
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-configure-module"
DESTINATION "${INSTALL_BINDIR}")
else()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bin/qt-configure-module.bat.in"
"${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-configure-module.bat" @ONLY)
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-configure-module.bat"
DESTINATION "${INSTALL_BINDIR}")
endif()
unset(__relative_path_to_processconfigureargs_script)
# Provide a private convenience wrapper to configure and build one or more standalone tests.
# Calling CMake directly on a Qt test project won't work because the project does not call
# find_package(Qt...) to get all dependencies like examples do.
@ -409,6 +433,7 @@ qt_copy_or_install(FILES
cmake/QtPrecompiledHeadersHelpers.cmake
cmake/QtPriHelpers.cmake
cmake/QtPrlHelpers.cmake
cmake/QtProcessConfigureArgs.cmake
cmake/QtQmakeHelpers.cmake
cmake/QtResourceHelpers.cmake
cmake/QtRpathHelpers.cmake