Commit Graph

29 Commits

Author SHA1 Message Date
Thiago Macieira
ce5eaeea59 headerscheck: enable exceptions for MSVC
MSVC's own headers trigger the C4530 warning just by being included.

  C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.33.31629\include\chrono(2206):
  error C2220: the following warning is treated as an error
  warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc

Change-Id: Ieab617d69f3b4b54ab30fffd175c02c23f677d75
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-05 16:17:41 -07:00
Fabian Kosmale
6854d35393 headersclean: Check fno-operator-names
KDE Frameworks tests this in one build configuration. Verify that we
do not break it in public Qt headers.

Task-number: QTBUG-110585
Change-Id: I5c976d00d7b1aba026e99acb9bad176103e23b0b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-01-26 14:19:33 +00:00
Kai Köhne
8bf602518d Enforce strict standards behavior in MSVC headersclean check
The comment apparently doesn't apply anymore.

Change-Id: Ie0572341c55d60b83ff428134ba803068fa20558
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-01-03 13:53:47 +01:00
Alexey Edelev
7f4aa1a3fa Remove perl related functionality from CMake files
Avoid using perl in CMake scripts. Remove the syncqt.pl specific
code.

Task-number: QTBUG-87480
Change-Id: I7fcd5cc83d173ec463c275b5b50b84f25044a118
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-11-29 12:35:47 +01:00
Alexey Edelev
8155bd5426 Avoid converting paths to relative for headersclean comment if they are relative
When calling file (RELATIVE_PATH), check if the base directory and
header path are absolute. Use the original file path if the paths are
relative to avoid critical errors.

Fixes: QTBUG-108617
Change-Id: I6daddd5c1553cdbfd965650b7c469673c62f0a3d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
2022-11-28 15:09:04 +01:00
Alexey Edelev
433d711670 Add NO_HEADERSCLEAN_CHECK flag to qt_internal_add_module
Some modules may have header files that do not pass headersclean check
under some conditions. It's nice to have an option in the
qt_internal_add_module function to disable the check for the modules of
this kind. At the moment this flag is useful for the ActiveQt module,
since it syncs and installs header files that don't belong to it.

Amends b89d63515b

Task-number: QTBUG-103196
Change-Id: I21a82d50d50bdac225ed483ab0cc50339c2a4873
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-10-27 16:49:42 +02:00
Alexey Edelev
d90935f2c2 Fix issues in qt_internal_add_headersclean_target
Avoid using top-level ${target} variable in the function. Align the
module's '_header_check_exceptions' file name, so it should use
_qt_module_interface_name property, but not the qt_module_include_name
proeprty as the prefix.

Amends b89d63515b

Task-number: QTBUG-87480
Change-Id: I1a3ceee1a29f2f4a7cb727310b4fdac63d8144e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-10-25 18:56:09 +02:00
Alexey Edelev
b89d63515b Replace the syncqt.pl script with syncqt tool
syncqt.pl adds an extra dependency on perl when building Qt. Modern C++
provides the convenient cross-platform way to access a filesystem and
to use regular expressions, so we may replace the perl script with C++
application. The syncqt executable is built at configure time and
installed as QtCore tool. It's running at configure time to deliver the
required header files for IDE to build a consistent code model and at
the build time to keep tracking changes in header files and generate
the missing aliases without reconfiguring. 'syncqt' only parses header
files from a CMake build tree, so the resulting Qt installation only
contains interfacing headers that belong to the platform that Qt is
built for. 'sync.profile' files are not used as the 'source of truth'
for sync qt procedure anymore, all the necessary information is taken
from either CMake files at configure time or from the module header
files while parsing them.

syncqt.pl is still in place since it's required as fallback solution
for a smooth transition to the new syncqt implementation for all qt
repositories.

This patchset only enables the C++ based syncqt for 'qtbase'
repository.

From the performance perspective C++ version works faster then perl
script, also the configure time is reduced significally on subsequent
reconfigurations - up x2 times faster when re-configuring repository,
but it also takes time to compile the tool itself the first time.
Numbers for qtbase:
           syncqt.pl  syncqt.cpp
 initial:  0m16,035s  0m20,413s
 reconfig: 0m6,819s   0m3,725s

The syncing procedure can be run separately for each module using
<ModuleName>_sync_headers targets. The 'sync_headers' target can be
used to sync all the modules at once.

Task-number: QTBUG-87480
Task-number: QTBUG-103196
Change-Id: I8c938bcaf88a8713b39bbfd66d9e7ef12b2c3523
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-27 13:12:11 +02:00
Lucie Gérard
32df595275 Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-23 23:58:42 +02:00
Alexey Edelev
c2c4a21374 Add the common headersclean_check target
Add headersclean_check that allows to run all module-specific
'_headersclean_check' targets in single command. Also add
dependency on input header files for the headers clean custom
commands.

Also adjust the '_headersclean_check' target names to match
the naming of module targets - the 'Qt' prefix is removed.

Change-Id: I17c3442c3c51ce99cd9b38c85d606e9ababbb013
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-08-09 15:21:52 +02:00
Lucie Gérard
fb1b20eab3 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-03 17:14:55 +02:00
Tor Arne Vestbø
030923c0de Add -Wshorten-64-to-32 to headersclean
Fix existing warnings by casting to the appropriate type.

Change-Id: Ic44d2a71e1a2e508199dbb46bea7a19e183ec42c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-21 17:14:08 +02:00
Marc Mutz
06f21a3870 headerclean: remove dead code
The variable was misspelt, so we obviously don't need these
exceptions.

Pick-to: 6.4 6.3 6.2
Change-Id: I691c9315bcde3aad72410ce01ae6dc6a013ee6fd
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-22 03:09:24 +02:00
Giuseppe D'Angelo
297fdcaf30 Enable QT_TYPESAFE_FLAGS in headersclean
Change-Id: Ie40a18af7f97b73ea79a09e0dea3fe08c56a1ebb
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-12 06:33:29 +01:00
Thiago Macieira
05e029619f CMake: fix running of headersclean targets when CMAKE_CXX_FLAGS is set
We were passing the full option from the user as a single string in the
command-line to the compiler.

clang++ -c "-O3 -g1 -march=tigerlake -mprefer-vector-width=256 -maes" [...]
error: invalid integral value '3 -g1 -march=tigerlake -mprefer-vector-width=256 -maes' in '-O3 -g1 -march=tigerlake -mprefer-vector-width=256 -maes'

Pick-to: 6.2 6.3
Fixes: QTBUG-100315
Change-Id: I6fcda969a9e9427198bffffd16ce83150d4e4263
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-31 19:07:58 -08:00
Thiago Macieira
cb0ea39895 CMake: remove support for building Qt with the old Intel compiler
This hasn't worked for some time. It's not in our CI and I don't think
it was working at all. When I tried to build it, I ran into several
problems with C++17 and an Internal Compiler Error I did not have any
interest in working around.

After discussing with the Intel compiler team, it was decided that
fixing those issues in the old compiler is not going to happen. Instead,
their recommendation is to adopt the new LLVM-based compiler, which
the last commit added support for.

This commit does not remove qmake support for the old ICC. It's possible
someone is using qmake with a non-Qt6 project and ICC.

Change-Id: Icb2516126f674e7b8bb3fffd16ad6350ddbd49e5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-13 12:49:49 -07:00
Thiago Macieira
63d80c7c4b CMake: add support for Intel's LLVM-based compiler
This includes a few cleanups to our .cmake files where it was easier to
combine existing sections of Clang / AppleClang that no longer needed to
be distinct.

icpx could be replaced with a shell script:
 exec `basename $0`/clang++ --intel "$@"

tst_qnumeric is not passing
FAIL!  : tst_QNumeric::classifyF() Compared values are not the same
   Actual   (qFpClassify(tiny / two)): 2
   Expected (FP_SUBNORMAL)           : 3
   Loc: [/home/tjmaciei/src/qt/qt6-icx/qtbase/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp(344)]
FAIL!  : tst_QNumeric::classifyD() Compared values are not the same
   Actual   (qFpClassify(tiny / two)): 2
   Expected (FP_SUBNORMAL)           : 3
   Loc: [/home/tjmaciei/src/qt/qt6-icx/qtbase/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp(344)]
FAIL!  : tst_QNumeric::floatDistance(denormal) Compared values are not the same
   Actual   (qFloatDistance(from, stop)): 0
   Expected (expectedDistance)          : 4194304
   Loc: [/home/tjmaciei/src/qt/qt6-icx/qtbase/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp(408)]
FAIL!  : tst_QNumeric::doubleDistance(denormal) Compared values are not the same
   Actual   (qFloatDistance(from, stop)): 0
   Expected (expectedDistance)          : 2251799813685248
   Loc: [/home/tjmaciei/src/qt/qt6-icx/qtbase/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp(408)]
P

Change-Id: Icb2516126f674e7b8bb3fffd16ad59431e8c3379
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-13 12:49:49 -07:00
Alexey Edelev
2483931e25 Add missing framework paths to header check targets
CMake doesn't add framework include paths for the includes if
add_custom_command is used. When all Qt modules are installed to a
single directory, frameworks could be found under
QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX, but for Conan builds
each module is installed to the separate directory. These directories
need to be listed in the QT_ADDITIONAL_PACKAGES_PREFIX_PATH variables
family. This takes into account directories that are listed in the
QT_ADDITIONAL_PACKAGES_PREFIX_PATH variables and considers they
can contain frameworks.

Pick-to: 6.2
Fixes: QTBUG-96511
Change-Id: I664381df4859a2e85c399cd94dc2f3996e452c03
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-20 17:54:12 +02:00
Kai Köhne
b58ca067da headersclean: Compile with -std=c++latest, -Zc:__cplusplus on MSVC
c++latest does check that our headers also work with upcoming C++20
support in MSVC. It also implicitly sets -permissive-, which checks for
stricter standards compliance.

Pick-to: 6.1
Task-number: QTBUG-91117
Change-Id: Iaf1547191969213d570a1b2f59888ad04a7977ab
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-03-04 09:40:56 +01:00
Kai Köhne
1702393644 Run headers_clean check with C++20 (gcc, clang)
The headers are already somewhat tested with C++17 in the regular
build. So let's try in the headers_clean check with C++20 instead.

Using C++20 with MSVC 19.28 doesn't work yet though:

  corelib/tools/qalgorithms.h(247): error C2039: 'popcount': is not a member of 'std'
  corelib/tools/qhashfunctions.h(311): note: see declaration of 'std'
  corelib/tools/qalgorithms.h(247): error C3861: 'popcount': identifier not found
  ...

Task-number: QTQAINFRA-4242
Change-Id: I1b48bcb9656fe1587fe03d3a17e3484c693aa295
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-02-15 13:16:54 +00:00
Joerg Bornemann
71e3857f7c Fix output files of the *_header_check targets
Header files of a Qt module are usually found in subdirectories.
Avoid creating object file paths like "header_foo/bar.h.o".
When building with conan, the "header_foo" subdirectory was not created
for whatever reason.

Now, we make sure we have clean object file paths, e.g.
"header_check/foo/bar.h.o", and we create the directory upfront before
invoking the compiler.

Fixes: QTBUG-90529
Change-Id: Ifa5d6b97e07fc4e249c58cda5128439d60b14f5f
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
(cherry picked from commit 54980200c79b466a276a4d3054390e4b3162e9ed)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-01-27 17:08:14 +00:00
Joerg Bornemann
bd8d74e0e2 Fix framework path for *_header_check targets
When building a Qt module against an installer-provided Qt on macOS, the
module pulls in the headersclean feature that creates the *_header_check
targets. Those targets try to compile the public headers of the module,
and the compilation command contains the -iframework argument. That
-iframework argument is supposed to point to the directory where the Qt
libs are installed. However, it pointed to the original
CMAKE_INSTALL_PREFIX of the machine where Qt was packaged.

Use the QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX variable instead
that contains the real installation location, even for an
installer-provided Qt.

Pick-to: 6.0
Fixes: QTBUG-90402
Change-Id: I27de8b3cc816488c2716042383b334d5c421452d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-01-19 20:59:29 +01:00
Alexandru Croitor
9b84ea6b47 CMake: Fix headersclean interaction with header only modules
Before CMake 3.19, we are not allowed to query non INTERFACE_ prefixed
property names from INTERFACE libraries. And it was the wrong thing
to do as well. Prefix the properties with INTERFACE_ as appropriate.

Don't try to add INTERFACE_COMPILE_DEFINITIONS from header only
modules to the headerclean compile commands. This causes configuration
issues with UiPlugin in qttools. Fortunately it seems that qmake
doesn't do that for 'header_module's either.

Finally don't query for the FRAMEWORK property on the passed target
(INTERFACE libs can't be frameworks). Instead just query if the whole
Qt build itself is a framework build.

An issue was discovered regarding QT_NO_ENTRYPOINT genexes breaking
headersclean add_custom_commands for UiPlugin in qttools. To avoid
this the property was renamed to all lower case in
6ca66de9120537134b63d42de6c53c6e5834e8f3. This avoided the immediate
issue, but it's possible it might resurface in the future with a
different property name that wasn't renamed. In particular I thought
it might happen with QT_NO_UTF8_SOURCE but it didn't.

In case something like that happens again, the two possible solutions
are to bump minimum CMake version requirement to 3.19 (where upper
case property names are allowed to be queried from INTERFACE libs) or
to implement recursive include directory fetching similar to our
qt_internal_walk_libs implementation.

Pick-to: 6.0
Task-number: QTBUG-86053
Task-number: QTBUG-82615
Change-Id: I7815d555ec9ea049a8fd40f2a2f072dcb9f5e9c3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-11-25 22:08:10 +01:00
Alexandru Croitor
5d81a5d4f9 CMake: Fix headersclean to build with proper flags
It's not sufficient to pass -I{prefix}/include when doing the header
clean check.

We need to propagate all target include directories and compile
definitions, and also the compile flags for good measure.

For macOS frameworks we also need to explicitly pass an -iframework
flag (qmake passses -F instead), to ensure that <QtGui/qfoo.h> style
includes are found when building other repos than qtbase.

Task-number: QTBUG-82615
Change-Id: I76d12340bc01c5c948ff04df9a3df384dcb7e076
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-23 01:32:39 +02:00
Alexandru Croitor
2a3a99fe44 CMake: Use compiler launcher for headerclean rules
This ensures ccache or sccache is used to cache the compilation of the
headerclean checks.

Task-number: QTBUG-82615
Change-Id: Ie944eb1d643e7271551c9f8337609741e419e9d8
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-23 01:32:34 +02:00
Alexandru Croitor
7c23281db3 CMake: Fix headersclean to work on macOS
It appears there's a difference between the chosen macOS compiler path
in the CI versus the compiler path on my local machine.

In the CI the chosen compiler path ends up 'being /usr/bin/clang++'
whereas for me locally it's

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++

For some reason the headersclean commands succeed in the CI, but
locally they fail for me saying that standard library includes can not
be found, unless an explicit sysroot flag is specified.

I assume that in the CI the '/usr/bin/clang++' compiler shim chooses some
implcit sysroot, whereas the longer Xcode compiler expects an explicit
sysroot.
It's probably also affected by the fact that in the CI we pass an
explicit CMAKE_OSX_SYSROOT to a non-standard Xcode location e.g.

/Applications/Xcode11.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk

Note the '11' in the Xcode app name.

Locally I don't pass a custom CMAKE_OSX_SYSROOT, and my Xcode is
installed in a regular location e.g /Applications/Xcode.app.

The sysroot flag and path is added to regular CXX compilation rules
inside CMake's core (in cmLocalGenerator.cxx).

Reuse the same variables that CMake uses and add them to our headersclean
command rules.

Task-number: QTBUG-82615
Change-Id: Ic03ea27e39471f5fa168eb5970bf3d3f1d1be251
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-23 01:32:29 +02:00
Kai Koehne
3b6ef98d7a headersclean: Fix include paths for dependent modules
Having ${QT_BUILD_DIR}/include as include path is not enough for
modules outside of qtbase. They also need to pick up headers from e.g.
Qt Core, which are available only in "${CMAKE_INSTALL_PREFIX}/include"

This amends db21bad936

Fixes: QTBUG-82615
Change-Id: Ib003a66ce039bf1ab6e21a3b1cd86923207eb3db
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-21 14:51:15 +00:00
Kai Koehne
146421ecaf headersclean: Check for all-W3 MSVC warnings
C4180, C4458 were disabled already in 2012, in commit 6668f5becf.
C4577 was disabled due to QtScript being compiled without exception
support in commit 97d7d80e73.

Anyhow, Qt Script is now officially gone in Qt 6, and Qt headers
do work just fine with C4180. Finally, C4458 is nowadays a W4 warning,
so not enabled in the first place.

Task-number: QTBUG-82615
Change-Id: I2f9b8e858817876b069a166129fbfac7ef3587a0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2020-08-26 17:30:40 +02:00
Kai Koehne
db21bad936 Port headersclean check to CMake
Configure Qt with -DQT_FEATURE_headersclean=ON to enable the
check. There will be separate target for each module include
(e.g. QtCore_header_check), but the check will also be done
when the module is built for the first time.

There are notable differences to the qmake version:
- the build does not pick up anymore default defines or flags from
  the module, or Qt. Instead options like -fPIC they have to be listed
  explicitly. Also for this reason, we have to skip the vulkan-related
  headers from the check, since vulkan/vulkan.h is not necessarily
  in the compiler's default search path.
- some checks for nowadays unsupported compiler versions are
  removed.
- -Wdouble-promotion -Wshorten-64-to-32 is not added for clang
  builds; the qmake code path did never enforce that on CI
  machines (it was non-Apple clang only), and the check currently
  fails on these configurations.

Fixes: QTBUG-82615
Change-Id: I1cd303677b1472116910b6c27748f96436feb35e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-08-25 21:13:08 +02:00