Commit Graph

87 Commits

Author SHA1 Message Date
Joerg Bornemann
1bb6779389 CMake: Let configure guess the compiler from mkspec argument
The arguments -platform, -xplatform and -device determine the mkspec
that's used for the qmake companion files.

If the user specifies a mkspec that indicates usage of clang or icc,
set the respective CMake variables to use one of those compilers.

Fixes: QTBUG-87836
Change-Id: I2b10d819b0eb92a97d7f79672547b1e2d821cf33
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-02 16:33:40 +01:00
Joerg Bornemann
cb7f4030bc CMake: Fix [qt-]configure[-module].bat arguments with backslashes
We must escape backslashes in CMake code that's to be evaluated and in
the arguments we read from config.opt.

Change-Id: I65d033c77f71888974983aa3d834acb2fe89f3fb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-30 08:22:35 +01:00
Joerg Bornemann
90e384d286 CMake: Fix CMake generator auto-selection on Windows
The variable to check for a Windows host system was mis-typed.

Change-Id: I25b14b80d25bfec0c1a00e99833520b6fb6a4b02
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2020-10-22 20:47:10 +02:00
Joerg Bornemann
9ff9a54bfb CMake: Fix INPUT_* names with dashes
In configure.json files we have inputs with dashes, e.g.
bundlex-xcb-xinput. In configure.cmake files, these are read in their
normalized form, e.g. INPUT_bundled_xcb_xinput.

Normalize the input names in QtProcessConfigureArgs.cmake like we
already do for feature names.

Change-Id: Iece414d40a0e9e2920580f2fda68e25cd32674c9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-22 18:06:19 +02:00
Joerg Bornemann
73f9c514dc CMake: Ignore license-related configure arguments
Do not print warnings for the configure arguments -commercial,
-opensource and -confirm-license. We're not removing the arguments yet
to keep existing build scripts working.

Fixes: QTBUG-86096
Change-Id: Ieb63e2f2b81c022e8559cde6c3e0be0b8ce655ca
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-17 23:27:31 +02:00
Joerg Bornemann
557d2adbe8 CMake: Autodetect Android toolchain file and NDK
The Android toolchain file is now autodetected from the location of the
NDK. The NDK location can be specified by setting the CMake variable
ANDROID_NDK_ROOT. Auto-detection of the Android toolchain file is the
only purpose of this variable.

In recent Android SDK installations the path to the NDK is well-known
and can be auto-detected too. If only ANDROID_SDK_ROOT is given, we try
to detect ANDROID_NDK_ROOT first and from that the Android toolchain
file.

Adjust the build instructions in cmake/README.md, and remove the part
where we suggest to set some environment variables that are only used to
create the cmake call.

Task-number: QTBUG-87068
Change-Id: Ia0df5df7651e98979e9cead1cdae7b17ecbc4afb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-13 19:44:45 +00:00
Joerg Bornemann
18357033b4 CMake: Fix the -sanitize configure option
This needs to map to ECM_ENABLE_SANITIZERS.

Fixes: QTBUG-87316
Change-Id: I9e983728af0ba69fd428944e647f0afae8c61772
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-12 13:57:56 +02:00
Alexandru Croitor
5b90b650a4 CMake: Implement missing iOS-related configure options
Detect an iOS build when either an -sdk option is passed
or when -xplatform macx-ios-clang is passed as a target
mkspec.

Now that CMake 3.17 is released, change the default behavior of the
iOS build to configure with simulator_and_device set to ON, like it
is with qmake.

Update the documentation regarding iOS configuration.

Change-Id: I91aaf706610b8d3c69f1ad4ba9dadee2b1e5db97
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-12 13:35:57 +02:00
Kai Koehne
ab4acdbeb1 Do not build tests and examples by default for configure -cmake
Tests were never built by default, except for -developer-build.
Examples were build, but aren't anymore by default if you
run cmake directly.

Let the default be figured out by cmake, and only set
BUILD_EXAMPLES and BUILD_TESTING if the user has
expicitly passed them via -make or -nomake.

Task-number: QTBUG-87217
Change-Id: I37321d96cc1e9e184a711a858c860b0205d5b74f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-08 11:12:30 +00:00
Joerg Bornemann
1f52f45836 CMake: Implement missing Android-related configure options
Implement the last remaining Android-related configure options for the
CMake build.

Print warnings for options that have no equivalent in the CMake build.

Let -android-ndk automatically deduce the CMake toolchain file, and
error out if that fails with a hint how to fix the situation.

Task-number: QTBUG-85373
Change-Id: I8399e5334ae0f1f6634e381775a308d34f7c482b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-06 06:31:18 +02:00
Joerg Bornemann
260a6e86c2 CMake: Extend message functions in QtProcessConfigureArgs.cmake
qtConfAddWarning was missing, despite being used.

All of the three qtConfAdd* functions take multiple parameters and pass
them to the CMake's message() function.

Change-Id: I1fad46c6fd00b2e733b32cda482bbf1341ffc63f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-06 06:31:18 +02:00
Joerg Bornemann
84485dfad3 CMake: Fix -[no-]warnings-are-errors configure argument
The CMake build uses the WARNINGS_ARE_ERRORS variable, and the feature
warnings_are_errors exists only in the qmake build.

Change-Id: I1e548b30b210b3dd1b2f23041d490a981312f4ba
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-01 14:56:23 +02:00
Cristian Adam
079cf55111 CMake Build: Add support for -qtlibinfix configure parameter
Rename all libQt6*.so to libQt6*<infix>.so

Task-number: QTBUG-85438
Change-Id: I4b91ffaaec7bea61454b0d3c794c77f2d0868d54
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-23 17:31:13 +02:00
Joerg Bornemann
25cc901f04 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>
2020-09-22 22:20:43 +02:00
Assam Boudjelthia
b9c85d6b0e CMake: build add flags for building QtAndroid.jar
Adds -source, -target, -Xlint:unchecked, -bootclasspath flags.

Setting default javac build source and target versions to 8.

Allow setting custom values for javac build versions via
-DQT_ANDROID_JAVAC_SOURCE, and -DQT_ANDROID_JAVAC_TARGET.

Task-number: QTBUG-86282
Change-Id: I98f4f193ac96016dc722d178594d7fd401202f68
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-16 20:55:16 +03:00
Joerg Bornemann
87fd930fca CMake: Fix qt-configure-module for modules without qt_cmdline.cmake
Some repos/modules don't have configure.json files and thus no
qt_cmdline.cmake files. Make qt-configure-module check for the file's
existence. As drive-by fix, surround the configure.cmake's path by
double quotes.

Change-Id: If1a91a0bba0c2fd282cfa08fa6ff2bb20f0a15ba
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-11 17:11:03 +02:00
Joerg Bornemann
96bdcdacbc CMake: Implement configure -ltcg
This configure switch sets the CMake variable
CMAKE_INTERPROCEDURAL_OPTIMIZATION_<CONFIG> per release config to ON.

The feature 'ltcg' is enabled if any of the variables
CMAKE_INTERPROCEDURAL_OPTIMIZATION,
CMAKE_INTERPROCEDURAL_OPTIMIZATION_<CONFIG> are ON.

In order to implement the check, configurejson2cmake had to be extended
to be able to write extra CMake code before and after the feature
definition. This extra code can be added to a feature mapping below the
keys "cmakePrelude" and "cmakeEpilogue".

Task-number: QTBUG-85373
Change-Id: Ia2eb907edcf087f137977a9b090705397f83eb05
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-11 11:30:56 +02:00
Joerg Bornemann
7ddb4dcad5 CMake: Implement configure -qpa
Change-Id: I38a938cda91a525d2af22deec864c6a12af3e29d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-11 00:41:20 +02:00
Joerg Bornemann
46f8c46bee CMake: Teach QtProcessConfigureArgs.cmake to configure other modules
Until now, QtProcessConfigureArgs.cmake could only handle qtbase and the
top-level build. Add the variable MODULE_ROOT that the user can point to
the module that is to be configured.

Example - QtDeclarative can now be configured like this:

cd qtdeclarative-build-dir
echo -qml-network > config.opt
cmake -DOPTFILE=config.opt -DMODULE_ROOT=<source-root>/qtdeclarative \
    -DCMAKE_COMMAND=<install-prefix>/bin/qt-cmake-private \
    -P <source-root>/qtbase/cmake/QtProcessConfigureArgs.cmake

A convenience script that saves the user from entering this unwieldy
incantation will be added in a subsequent commit.

Change-Id: If46103de3a8eb84b15e7600ebfec25544451e1d5
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-02 23:44:03 +02:00
Joerg Bornemann
7e7c9ba455 CMake: Support configure tests of type 'linkerSupportsFlag'
Task-number: QTBUG-86155
Change-Id: I3764d99cd4ad1c432b499ec9ba7c4c48391fa421
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-23 11:04:46 +02:00
Joerg Bornemann
c8fda317ea CMake: Fix configure setting superfluous features
Command line options like -debug result in setting the variable
INPUT_debug. INPUT_debug is mapped to the CMake argument
-DCMAKE_BUILD_TYPE=Debug. INPUT_debug also matches the feature
'debug', and the CMake argument -DFEATURE_debug=ON was passed.

Do not pass -DFEATURE_xxx CMake arguments for inputs that are already
handled.

Change-Id: If096dff1c6dd694545c6f671f5f3512a43c3ec50
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-23 11:04:38 +02:00
Joerg Bornemann
df28355981 CMake: Support configure tests of type 'compilerSupportsFlag'
Task-number: QTBUG-86155
Change-Id: Iaa5c48b6508870a0f6afdf9df66cd2e634fe19b3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-20 17:07:46 +02:00
Joerg Bornemann
5f729da74a CMake: Implement configure -qreal <type>
The configure argument -qreal <type> maps to the CMake argument
-DQT_COORD_TYPE=<type>.

Fixes: QTBUG-83325
Change-Id: I94970f31ccfb241b1dd4f1d9b6cef25d6684dc05
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-19 08:28:50 +02:00
Joerg Bornemann
d6e41abd62 CMake: Handle -D, -I, -F and -L configure arguments
Introduce new CMake variables and map
-D to QT_EXTRA_DEFINES,
-I to QT_EXTRA_INCLUDEPATHS,
-L to QT_EXTRA_LIBDIRS,
and -F to QT_EXTRA_FRAMEWORKPATHS.

Those variables only affect the Qt build, not user projects.

Fixes: QTBUG-85878
Change-Id: I229df2eed1505a2619068d0d32975962b052569a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-17 18:19:24 +02:00
Joerg Bornemann
f107713452 CMake: De-duplicate list input handling code in QtProcessConfigureArgs
Change-Id: I9fd77dd81f67fcc9a0306ab0d627257f209cdb08
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-17 08:08:26 +02:00
Joerg Bornemann
584d4be174 CMake: Re-implement configure/qmake's command line handling in CMake
We extend configurejson2cmake to read the "commandline"
information from configure.json. This data is then translated to CMake function
calls and written it into commandline.cmake files.

We extend QtProcessConfigureArgs.cmake to pick up those commandline.cmake
files to feed our command line handling code, which is a
re-implementation of the command line handling in qt_configure.prf.

The command line handler sets INPUT_xxx variables, similar to
configure/qmake's config.input.xxx variables. The INPUT_xxx values are
translated
- to -DFEATURE_xxx=ON/OFF arguments if the input represents a feature,
- to corresponding CMake variables if such a variable is known,
- or to -DINPUT_xxx=yyy CMake arguments.

Configure arguments that have an entry in
cmake/configure-cmake-mapping.md are actually implemented. Other
arguments are likely to need more work.

Task-number: QTBUG-85373
Change-Id: Ia96baa673fc1fb88e73ba05a1afb473aa074b37d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-17 08:08:20 +02:00
Joerg Bornemann
22b663f55d CMake: Fix -pch configure option
This amends dbd3c75965.

Change-Id: Ia87d60f1da65624bc5c6ffb915eecf99a2d8bdc0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:09:18 +02:00
Joerg Bornemann
544b08f664 CMake: Support the -rpath configure argument
Task-number: QTBUG-85373
Change-Id: I04bdf307556aeab607a95d153cbe19254044c1f4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:09:14 +02:00
Joerg Bornemann
619ec7bc15 CMake: Support the -c++std configure argument
Task-number: QTBUG-85373
Change-Id: I071c1d0c8bf96b34c5733d039b8a61e54e416800
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:09:10 +02:00
Joerg Bornemann
23216a6193 CMake: Support the -qtnamespace configure argument
Task-number: QTBUG-85373
Change-Id: I3f995b31339a3c2b0c97ca806c652bc67846fc69
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:09:05 +02:00
Joerg Bornemann
63e90281b2 CMake: Support mkspec-related configure arguments
Task-number: QTBUG-85373
Change-Id: I44ae15b4c05f23442ac6b9d69d31f22f01d0a48c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:09:00 +02:00
Joerg Bornemann
fe5fa1d974 CMake: Support -static, -shared and -framework configure arguments
Task-number: QTBUG-85373
Change-Id: I0a1db7dcb4cb1738fa1ba0a687d41c5f5a613364
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-08 07:08:56 +02:00
Joerg Bornemann
26fbf8082c CMake: Support configure -force_debug_info
Task-number: QTBUG-85373
Change-Id: Ia798fc2cf715aed9157e1d9e2f64187c16e38bcf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-06 17:44:01 +02:00
Joerg Bornemann
dd77597252 CMake: Support build config-related configure options
This add support for the following options: -debug, -release,
-debug-and-release. For the latter, the "Ninja Multi-Config" generator
is auto-detected, if ninja is available.

Task-number: QTBUG-85373
Change-Id: Ide0ca44e5f4c74657147e89d71e8d71c4f6a4c45
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-06 17:43:52 +02:00
Joerg Bornemann
ab559e25af CMake: Support -bindir, -libdir, -*dir configure arguments
Task-number: QTBUG-85373
Change-Id: I0df181cb017561c3f0af5ab3fecb76008b89c0d2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-06 17:43:42 +02:00
Joerg Bornemann
3ac054d6a8 CMake: Re-work configure flags for CMake generators
Remove the -cmake-makefiles configure argument as its meaning was in
essence "do not pass a -G argument to CMake".
Instead, we add the following arguments:
    -cmake-generator <name> to pass -G <name> to CMake
    -cmake-use-default-generator to pass no -G argument to CMake

If none of those arguments is given, we try to autodetect the
generator. If a ninja executable is found, we prefer the Ninja
generator. On Unix we fall back to "Unix Makefiles".
On Windows, we do a poor man's compiler detection and select one of
"NMake Makefiles", "NMake Makefiles JOM" and "MinGW Makefiles".

Change-Id: Ic36669bd50956d15fbc71cee73720732cd4bfab8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-06 17:43:35 +02:00
Joerg Bornemann
dbd3c75965 CMake: Teach configure.bat the -cmake argument
The configure scripts need to translate configure options to CMake
arguments. It is not sensible to implement this translation twice, in
sh and Windows batch language, so we're doing this once, in CMake
language.

The configure scripts write their options into config.opt and call a
CMake script that reads config.opt, does the translation to CMake
arguments and calls CMake to generate the build system.

While we're at it, implement some more translations than the sh
configure provided, like -extprefix, -top-level and -skip.

Fixes: QTBUG-85349
Fixes: QTBUG-85350
Task-number: QTBUG-85373
Change-Id: Ida5d8b2a3c178b9349d41ec76d190c69a9456e74
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-07-06 17:43:28 +02:00