CMake: Fix configure -redo for top-level builds

When re-doing in a top-level build, we did not read the config.opt file
from the top-level directory.

Also, the config.opt file should not contain the -top-level argument.
This is an internal option, and on Windows, it was already missing. The
information whether we're doing a top-level build is now passed in the
CMake variable TOP_LEVEL.

Change-Id: Iaecd7306a4b6d9ad494684c201cf12f8e74d684b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2020-09-17 12:16:47 +02:00
parent 8d4eb292b2
commit 25cc901f04
3 changed files with 22 additions and 13 deletions

View File

@ -6,6 +6,7 @@
# with one option per line.
# MODULE_ROOT: The source directory of the module to be built.
# If empty, qtbase/top-level is assumed.
# TOP_LEVEL: TRUE, if this is a top-level build.
include(${CMAKE_CURRENT_LIST_DIR}/QtFeatureCommon.cmake)
@ -31,7 +32,15 @@ else()
endif()
set(configure_filename "configure.cmake")
set(commandline_filename "qt_cmdline.cmake")
set(commandline_files "${MODULE_ROOT}/${commandline_filename}")
if(TOP_LEVEL)
get_filename_component(MODULE_ROOT "../.." ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
file(GLOB commandline_files "${MODULE_ROOT}/*/${commandline_filename}")
if(EXISTS "${MODULE_ROOT}/${commandline_filename}")
list(PREPEND commandline_files "${MODULE_ROOT}/${commandline_filename}")
endif()
else()
set(commandline_files "${MODULE_ROOT}/${commandline_filename}")
endif()
file(STRINGS "${OPTFILE}" configure_args)
list(FILTER configure_args EXCLUDE REGEX "^[ \t]*$")
list(TRANSFORM configure_args STRIP)
@ -47,12 +56,6 @@ while(configure_args)
list(POP_FRONT configure_args generator)
elseif(arg STREQUAL "-cmake-use-default-generator")
set(auto_detect_generator FALSE)
elseif(arg STREQUAL "-top-level")
get_filename_component(MODULE_ROOT "../.." ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
file(GLOB commandline_files "${MODULE_ROOT}/*/${commandline_filename}")
if(EXISTS "${MODULE_ROOT}/${commandline_filename}")
list(PREPEND commandline_files "${MODULE_ROOT}/${commandline_filename}")
endif()
elseif(arg STREQUAL "-skip")
list(POP_FRONT configure_args qtrepo)
push("-DBUILD_${qtrepo}=OFF")

14
configure vendored
View File

@ -559,8 +559,8 @@ while [ "$#" -gt 0 ]; do
BUILD_WITH_CMAKE=yes
;;
redo)
if [ -f config.opt ]; then
if grep -e ^-cmake <config.opt; then
if [ -f ${outpathPrefix}config.opt ]; then
if grep -e ^-cmake <${outpathPrefix}config.opt >/dev/null 2>&1; then
BUILD_WITH_CMAKE=yes
fi
fi
@ -917,31 +917,35 @@ else
fi
}
checkTopLevelBuild "$@"
parseCommandline "$@"
handleHelp
if [ "$BUILD_WITH_CMAKE" = "yes" ]; then
checkTopLevelBuild "$@"
getOptAndQMakeCmdLines "$@"
optfilename=config.opt
if [ -z "$optfile" ]; then # only write optfile if not currently redoing
optfilepath=${outpathPrefix}${optfilename}
if [ -f "$optfilepath" ]; then rm "$optfilepath"; fi
for arg in "$@"; do
if [ "$arg" = "-top-level" ]; then
continue
fi
echo $arg >> "$optfilepath"
done
fi
top_level_arg=
if [ -n "$CFG_TOPLEVEL" ]; then
top_level_arg=-DTOP_LEVEL=TRUE
cd ..
fi
cmake "-DOPTFILE=$optfilename" -P "$relpath/cmake/QtProcessConfigureArgs.cmake"
cmake "-DOPTFILE=$optfilename" $top_level_arg -P "$relpath/cmake/QtProcessConfigureArgs.cmake"
else
findPerl
findAwk
findMake
checkQMakeEnv
checkTopLevelBuild "$@"
getOptAndQMakeCmdLines "$@"
detectOperatingSystem
maybeVerifyXcode

View File

@ -316,4 +316,6 @@ if "%rargs%" == "" (
rem Launch CMake-based configure
cd "%TOPQTDIR%"
cmake -DOPTFILE=config.opt -P "%QTSRC%\cmake\QtProcessConfigureArgs.cmake"
set TOP_LEVEL_ARG=
if %TOPLEVEL% == true set TOP_LEVEL_ARG=-DTOP_LEVEL=TRUE
cmake -DOPTFILE=config.opt %TOP_LEVEL_ARG% -P "%QTSRC%\cmake\QtProcessConfigureArgs.cmake"