Skip to content

Commit

Permalink
CMake: Fix configure -redo for top-level builds
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jobor committed Sep 22, 2020
1 parent 8d4eb29 commit 25cc901
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
17 changes: 10 additions & 7 deletions cmake/QtProcessConfigureArgs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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")
Expand Down
14 changes: 9 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion configure.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 25cc901

Please sign in to comment.