diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-01-31 11:43:22 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2020-02-03 15:01:53 +0000 |
commit | 4e7af2061e8c323b2a21f0549643a2cfab191664 (patch) | |
tree | 54c6046915aee4a91eb6178183c022b8e547d244 /configure | |
parent | 6251963ecd26bfc480b2871e26b6df4d7ab88cee (diff) | |
parent | 3f386095adc6c280008c7e811e88f0215f1d862f (diff) |
Merge remote-tracking branch 'origin/wip/cmake' into dev
This pulls the CMake port, which not only adds CMake files but also
modifies existing code. A brief summary of "seemingly unrelated" changes:
* configure.json was re-formatted to not use multi-line strings. That
is an extension of the Qt JSON parser but not JSON compliant, which
is needed for the configure.json-to-cmake conversion script (python).
* Some moc inclusions were added due to CMake's slightly different way
of handling moc. With the changes the files build with qmake and cmake.
* Since CMake just grep's for the Q_OBJECT macro to determine whether to
call moc (instead of doing pre-processing like qmake), the existing use
of "Q_OBJECT" in our documentation was changed to \Q_OBJECT, which cmake
doesn't see and which is now a qdoc macro.
* QTestLib's qFindTestData was extended to also search in the source
directory known at build time.
What this change also brings is a new way of building modules in Coin by using
YAML configuration files that describe the steps of building and testing in Coin
specific terms. The platform configuration files in qt5 are instructed to use the
old Coin built-in way of testing ("UseLegacyInstructions" feature) but for any
configurations that do not have this, these yaml files in the coin/ sub-directory
are used and shared across repositories.
Change-Id: I1d832c3400e8d6945ad787024ba60e7440225c08
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 218 |
1 files changed, 183 insertions, 35 deletions
@@ -42,18 +42,27 @@ outpath=`/bin/pwd` WHICH="which" +PERL= +findPerl() +{ PERL=`$WHICH perl 2>/dev/null` +} # find out which awk we want to use, prefer gawk, then nawk, then regular awk AWK= +findAwk() +{ for e in gawk nawk awk; do if "$WHICH" $e >/dev/null 2>&1 && ( $e -f /dev/null /dev/null ) >/dev/null 2>&1; then AWK=$e break fi done +} # find a make command +findMake() +{ if [ -z "$MAKE" ]; then MAKE= for mk in gmake make; do @@ -70,39 +79,112 @@ if [ -z "$MAKE" ]; then # export MAKE, we need it later in the config.tests export MAKE fi +} # make sure qmake is not confused by these. recursion via Makefiles would # be still affected, so just unsetting them here is not an option. +checkQMakeEnv() +{ if [ -n "$QMAKESPEC" ] || [ -n "$XQMAKESPEC" ] || \ [ -n "$QMAKEPATH" ] || [ -n "$QMAKEFEATURES" ]; then echo >&2 "Please make sure to unset the QMAKESPEC, XQMAKESPEC, QMAKEPATH," echo >&2 "and QMAKEFEATURES environment variables prior to building Qt." exit 1 fi +} # do this early so we don't store it in config.status CFG_TOPLEVEL= -relpathMangled=$relpath outpathPrefix= -if [ x"$1" = x"-top-level" ]; then - CFG_TOPLEVEL=yes - relpathMangled=`dirname "$relpath"` - outpathPrefix=../ - shift -else - if [ -f ../.qmake.super ]; then - echo >&2 "ERROR: You cannot configure qtbase separately within a top-level build." - exit 1 + +checkTopLevelBuild() +{ + relpathMangled=$relpath + if [ x"$1" = x"-top-level" ]; then + CFG_TOPLEVEL=yes + relpathMangled=`dirname "$relpath"` + outpathPrefix=../ + else + if [ -f ../.qmake.super ]; then + echo >&2 "ERROR: You cannot configure qtbase separately within a top-level build." + exit 1 + fi fi +} + +CMAKE_CMDLINE= +getCMakeCmdLine() +{ +PASSTHRU= +set -f # suppress globbing in for loop +SAVED_IFS=$IFS +IFS=' +' + +if [ "$CFG_DEV" = "yes" ]; then + CMAKE_CMDLINE="$CMAKE_CMDLINE +-DFEATURE_developer_build=ON" + CMAKE_CMDLINE="$CMAKE_CMDLINE +-DBUILD_TESTING=ON" + CMAKE_CMDLINE="$CMAKE_CMDLINE +-DBUILD_EXAMPLES=ON" +fi + +if [ "$CMAKE_MAKEFILES" = "no" ]; then + CMAKE_CMDLINE="$CMAKE_CMDLINE +-G Ninja" fi +for i in "$@"; do + if [ "$PASSTHRU" = "yes" ]; then + CMAKE_CMDLINE="$CMAKE_CMDLINE +$i" + else + case $i in + -feature-*) + VAR=`echo $i | sed 's,^-feature-\(.*\),\1,'` + CMAKE_CMDLINE="$CMAKE_CMDLINE +-DQT_FEATURE_${VAR}=ON" + ;; + -no-feature-*) + VAR=`echo $i | sed 's,^-no-feature-\(.*\),\1,'` + CMAKE_CMDLINE="$CMAKE_CMDLINE +-DQT_FEATURE_${VAR}=OFF" + ;; + --no-*) + VAR=`echo $i | sed 's,^--no-\(.*\),\1,'` + CMAKE_CMDLINE="$CMAKE_CMDLINE +-DFEATURE_${VAR}=OFF" + ;; + -no-*) + VAR=`echo $i | sed 's,^-no-\(.*\),\1,'` + CMAKE_CMDLINE="$CMAKE_CMDLINE +-DFEATURE_${VAR}=OFF" + ;; + --) + PASSTHRU=yes + ;; + *) + ;; + esac + fi +done +set +f +IFS=$SAVED_IFS +} + OPT_CMDLINE= # expanded version for the script QMAKE_CMDLINE= # verbatim version for qmake call +getOptAndQMakeCmdLines() +{ set -f # suppress globbing in for loop SAVED_IFS=$IFS IFS=' ' for i in "$@"; do + if [ x"$i" = x"-top-level" ]; then + continue + fi case $i in -redo|--redo) optfile=${outpathPrefix}config.opt @@ -132,6 +214,7 @@ for i in $OPT_CMDLINE; do done set +f IFS=$SAVED_IFS +} #------------------------------------------------------------------------------- # utility functions @@ -298,7 +381,8 @@ getQMakeConf() #------------------------------------------------------------------------------- # operating system detection #------------------------------------------------------------------------------- - +detectOperatingSystem() +{ # need that throughout the script UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown @@ -312,11 +396,12 @@ if [ "$OSTYPE" = "msys" ]; then relpath=`(cd "$relpath"; pwd -W)` outpath=`pwd -W` fi - +} #------------------------------------------------------------------------------- # Verify Xcode installation on Mac OS #------------------------------------------------------------------------------- - +maybeVerifyXcode() +{ if [ "$BUILD_ON_MAC" = "yes" ]; then if ! /usr/bin/xcode-select --print-path >/dev/null 2>&1; then echo >&2 @@ -339,7 +424,7 @@ if [ "$BUILD_ON_MAC" = "yes" ]; then fi fi fi - +} #----------------------------------------------------------------------------- # Qt version detection #----------------------------------------------------------------------------- @@ -347,6 +432,8 @@ QT_VERSION= QT_MAJOR_VERSION= QT_MINOR_VERSION=0 QT_PATCH_VERSION=0 +detectQtVersion() +{ eval `sed -n -e 's/^MODULE_VERSION = \(\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*\)$/QT_VERSION=\1\ QT_MAJOR_VERSION=\2\ QT_MINOR_VERSION=\3\ @@ -356,7 +443,7 @@ if [ -z "$QT_MAJOR_VERSION" ]; then echo "Cannot proceed." exit 1 fi - +} #------------------------------------------------------------------------------- # initialize variables #------------------------------------------------------------------------------- @@ -372,11 +459,14 @@ OPT_VERBOSE=no OPT_HELP= CFG_SILENT=no CFG_DEV=no +BUILD_WITH_CMAKE=no +CMAKE_MAKEFILES=no #------------------------------------------------------------------------------- # parse command line arguments #------------------------------------------------------------------------------- - +parseCommandline() +{ # parse the arguments, setting things to "yes" or "no" while [ "$#" -gt 0 ]; do CURRENT_OPT="$1" @@ -521,6 +611,13 @@ while [ "$#" -gt 0 ]; do # need to keep this here, to ensure qmake is built silently CFG_SILENT="$VAL" ;; + cmake) + BUILD_WITH_CMAKE=yes + ;; + cmake-makefiles) + BUILD_WITH_CMAKE=yes + CMAKE_MAKEFILES=yes + ;; *) ;; esac @@ -530,11 +627,12 @@ while [ "$#" -gt 0 ]; do fi done [ "x$ERROR" = "xyes" ] && exit 1 - +} #------------------------------------------------------------------------------- # help - interactive parts of the script _after_ this section please #------------------------------------------------------------------------------- - +handleHelp() +{ if [ "$OPT_HELP" = "yes" ]; then cat $relpath/config_help.txt if [ -n "$CFG_TOPLEVEL" ]; then @@ -549,12 +647,13 @@ if [ "$OPT_HELP" = "yes" ]; then fi exit 0 fi - +} #------------------------------------------------------------------------------- # platform detection #------------------------------------------------------------------------------- - PLATFORM_NOTES= +detectPlatform() +{ if [ -z "$PLATFORM" ]; then case "$UNAME_SYSTEM:$UNAME_RELEASE" in Darwin:*) @@ -620,11 +719,13 @@ if [ -z "$PLATFORM" ]; then esac fi echo "$PLATFORM_NOTES" > "${outpathPrefix}.config.notes" +} #------------------------------------------------------------------------------- # command line and environment validation #------------------------------------------------------------------------------- - +validateEnv() +{ if [ -d "$PLATFORM" ]; then QMAKESPEC="$PLATFORM" else @@ -654,11 +755,12 @@ if [ '!' -d "$QMAKESPEC" ]; then echo exit 2 fi - +} #------------------------------------------------------------------------------- # build tree initialization #------------------------------------------------------------------------------- - +initBuildTree() +{ # is this a shadow build? if [ "$OPT_SHADOW" = "maybe" ]; then OPT_SHADOW=no @@ -686,11 +788,24 @@ if [ "$OPT_SHADOW" = "yes" ]; then mkdir -p "$outpath/mkspecs" fi +} + +# $1: input variable name (awk regexp) +# $2: optional output variable name +# $3: optional value transformation (sed command) +# relies on $QMAKESPEC, $COMPILER_CONF and $mkfile being set correctly, as the latter +# is where the resulting variable is written to +setBootstrapVariable() +{ + getQMakeConf "$1" | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile" +} # ----------------------------------------------------------------------------- # build qmake # ----------------------------------------------------------------------------- +buildQMake() +{ # symlink includes if [ -e "$relpath/.git" ]; then if [ -z "$PERL" ]; then @@ -702,17 +817,6 @@ if [ -e "$relpath/.git" ]; then "$relpath/bin/syncqt.pl" -version $QT_VERSION -minimal -module QtCore "$relpath" || exit 1 fi - -# $1: input variable name (awk regexp) -# $2: optional output variable name -# $3: optional value transformation (sed command) -# relies on $QMAKESPEC, $COMPILER_CONF and $mkfile being set correctly, as the latter -# is where the resulting variable is written to -setBootstrapVariable() -{ - getQMakeConf "$1" | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile" -} - # build qmake echo "Creating qmake..." mkdir -p "$outpath/qmake" || exit @@ -811,11 +915,14 @@ setBootstrapVariable() fi echo "Done." fi +} #------------------------------------------------------------------------------- # create a qt.conf for the Qt build tree itself #------------------------------------------------------------------------------- +createQtConf() +{ # Note that this file is just sufficient to boot configure, by which it is # replaced in-place with a version which is suitable for building all of Qt. QTCONFFILE="$outpath/bin/qt.conf" @@ -832,11 +939,13 @@ if [ x"$relpath" != x"$outpath" ]; then Prefix=$relpath EOF fi +} #------------------------------------------------------------------------------- # configure and build top-level makefile #------------------------------------------------------------------------------- - +createToplevelMakefile() +{ # recreate command line for qmake set -f SAVED_IFS=$IFS @@ -857,3 +966,42 @@ if [ -n "$CFG_HOST_QT_TOOLS_PATH" ]; then else "$outpath/bin/qmake" "$relpathMangled" -- "$@" fi +} + +runCMake() +{ +# recreate command line for cmake +set -f +SAVED_IFS=$IFS +IFS=' +' +for i in $CMAKE_CMDLINE; do + set -- $* "$i" +done +set +f +IFS=$SAVED_IFS +cmake $* "$relpath" +} + +parseCommandline "$@" +handleHelp +if [ "$BUILD_WITH_CMAKE" = "yes" ]; then + getCMakeCmdLine $@ + runCMake +else + findPerl + findAwk + findMake + checkQMakeEnv + checkTopLevelBuild "$@" + getOptAndQMakeCmdLines "$@" + detectOperatingSystem + maybeVerifyXcode + detectQtVersion + detectPlatform + validateEnv + initBuildTree + buildQMake + createQtConf + createToplevelMakefile +fi |