Skip to content

Commit 8ffb6ce

Browse files
committed
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 5c40cb0 Pick-to: 6.5 6.6 Change-Id: Id47c56a24561410aec6fbaa79b13fc8a78d12ed0 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
1 parent 5c8910a commit 8ffb6ce

5 files changed

+44
-2
lines changed

cmake/QtWrapperScriptHelpers.cmake

+39
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ function(qt_internal_create_wrapper_scripts)
208208
DESTINATION "${INSTALL_LIBEXECDIR}")
209209

210210
qt_internal_create_qt_configure_tests_wrapper_script()
211+
qt_internal_create_qt_configure_redo_script()
211212
endfunction()
212213

213214
function(qt_internal_create_qt_configure_tests_wrapper_script)
@@ -255,3 +256,41 @@ function(qt_internal_create_qt_configure_tests_wrapper_script)
255256
DESTINATION "${INSTALL_BINDIR}")
256257
endif()
257258
endfunction()
259+
260+
# Create a shell wrapper script to reconfigure Qt with the original configure arguments and
261+
# any additional ones passed.
262+
#
263+
# Removes CMakeCache.txt and friends, either manually, or using CMake's --fresh.
264+
#
265+
# The script is created in the root of the build dir and is called config.redo
266+
# It has the same contents as the 'config.status' script we created in qt 5.
267+
function(qt_internal_create_qt_configure_redo_script)
268+
set(input_script_name "qt-internal-config.redo")
269+
set(input_script_path "${CMAKE_CURRENT_SOURCE_DIR}/libexec/${input_script_name}")
270+
271+
# We don't use QT_BUILD_DIR because we want the file in the root of the build dir in a top-level
272+
# build.
273+
set(output_script_name "config.redo")
274+
set(output_path "${CMAKE_BINARY_DIR}/${output_script_name}")
275+
276+
if(QT_SUPERBUILD)
277+
set(configure_script_path "${Qt_SOURCE_DIR}")
278+
else()
279+
set(configure_script_path "${QtBase_SOURCE_DIR}")
280+
endif()
281+
string(APPEND configure_script_path "/configure")
282+
283+
# Used in the file contents.
284+
file(TO_NATIVE_PATH "${configure_script_path}" configure_path)
285+
286+
if(CMAKE_HOST_UNIX)
287+
string(APPEND input_script_path ".in")
288+
set(newline_style "LF")
289+
else()
290+
string(APPEND input_script_path ".bat.in")
291+
string(APPEND output_path ".bat")
292+
set(newline_style "CRLF")
293+
endif()
294+
295+
configure_file("${input_script_path}" "${output_path}" @ONLY NEWLINE_STYLE ${newline_style})
296+
endfunction()

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ determineOptFilePath "$@"
136136
optfilepath=${outpathPrefix}/config.opt
137137
opttmpfilepath=${outpathPrefix}/config.opt.in
138138

139-
redofilepath=${outpathPrefix}/config.redo
139+
redofilepath=${outpathPrefix}/config.redo.last
140140
redotmpfilepath=${outpathPrefix}/config.redo.in
141141

142142
fresh_requested_arg=

configure.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ cd "%TOPQTDIR%"
7979
rem Write config.opt if we're not currently -redo'ing
8080
set OPT_FILE_PATH=%TOPQTDIR%\config.opt
8181
set OPT_TMP_FILE_PATH=%TOPQTDIR%\config.opt.in
82-
set REDO_FILE_PATH=%TOPQTDIR%\config.redo
82+
set REDO_FILE_PATH=%TOPQTDIR%\config.redo.last
8383
set REDO_TMP_FILE_PATH=%TOPQTDIR%\config.redo.in
8484
set FRESH_REQUESTED_ARG=
8585
if not defined redoing (
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@configure_path@ -redo %*

libexec/qt-internal-config.redo.in

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
@configure_path@ -redo "$@"

0 commit comments

Comments
 (0)