CMake: Add a config.redo script similar to qt5's config.status

The config.redo script can be executed to reconfigure a pre-existing
qt build dir with the configure options that were last passed to the
build.

It just calls the original configure script with the -redo option.

It's nicer than calling configure + -redo manually because you don't
need to write out the full source path for configure.

In qt 5 times this script was called config.status.

On windows the script is called config.redo.bat.

Rename the config.redo file that QtWriteArgsFile.cmake writes to
to config.redo.last, so it doesn't conflict with the name of new
config.redo script.

Amends 5c40cb0f1a

Pick-to: 6.5 6.6
Change-Id: Id47c56a24561410aec6fbaa79b13fc8a78d12ed0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2023-09-01 16:39:59 +02:00
parent 5c8910adfd
commit 8ffb6ce64c
5 changed files with 44 additions and 2 deletions

View File

@ -208,6 +208,7 @@ function(qt_internal_create_wrapper_scripts)
DESTINATION "${INSTALL_LIBEXECDIR}")
qt_internal_create_qt_configure_tests_wrapper_script()
qt_internal_create_qt_configure_redo_script()
endfunction()
function(qt_internal_create_qt_configure_tests_wrapper_script)
@ -255,3 +256,41 @@ function(qt_internal_create_qt_configure_tests_wrapper_script)
DESTINATION "${INSTALL_BINDIR}")
endif()
endfunction()
# Create a shell wrapper script to reconfigure Qt with the original configure arguments and
# any additional ones passed.
#
# Removes CMakeCache.txt and friends, either manually, or using CMake's --fresh.
#
# The script is created in the root of the build dir and is called config.redo
# It has the same contents as the 'config.status' script we created in qt 5.
function(qt_internal_create_qt_configure_redo_script)
set(input_script_name "qt-internal-config.redo")
set(input_script_path "${CMAKE_CURRENT_SOURCE_DIR}/libexec/${input_script_name}")
# We don't use QT_BUILD_DIR because we want the file in the root of the build dir in a top-level
# build.
set(output_script_name "config.redo")
set(output_path "${CMAKE_BINARY_DIR}/${output_script_name}")
if(QT_SUPERBUILD)
set(configure_script_path "${Qt_SOURCE_DIR}")
else()
set(configure_script_path "${QtBase_SOURCE_DIR}")
endif()
string(APPEND configure_script_path "/configure")
# Used in the file contents.
file(TO_NATIVE_PATH "${configure_script_path}" configure_path)
if(CMAKE_HOST_UNIX)
string(APPEND input_script_path ".in")
set(newline_style "LF")
else()
string(APPEND input_script_path ".bat.in")
string(APPEND output_path ".bat")
set(newline_style "CRLF")
endif()
configure_file("${input_script_path}" "${output_path}" @ONLY NEWLINE_STYLE ${newline_style})
endfunction()

2
configure vendored
View File

@ -136,7 +136,7 @@ determineOptFilePath "$@"
optfilepath=${outpathPrefix}/config.opt
opttmpfilepath=${outpathPrefix}/config.opt.in
redofilepath=${outpathPrefix}/config.redo
redofilepath=${outpathPrefix}/config.redo.last
redotmpfilepath=${outpathPrefix}/config.redo.in
fresh_requested_arg=

View File

@ -79,7 +79,7 @@ cd "%TOPQTDIR%"
rem Write config.opt if we're not currently -redo'ing
set OPT_FILE_PATH=%TOPQTDIR%\config.opt
set OPT_TMP_FILE_PATH=%TOPQTDIR%\config.opt.in
set REDO_FILE_PATH=%TOPQTDIR%\config.redo
set REDO_FILE_PATH=%TOPQTDIR%\config.redo.last
set REDO_TMP_FILE_PATH=%TOPQTDIR%\config.redo.in
set FRESH_REQUESTED_ARG=
if not defined redoing (

View File

@ -0,0 +1 @@
@configure_path@ -redo %*

View File

@ -0,0 +1,2 @@
#!/bin/sh
@configure_path@ -redo "$@"