1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-18 00:02:21 +08:00
Commit Graph

78 Commits

Author SHA1 Message Date
Brad King
d8b6a750a0 Merge topic 'windows-tidy-cmstrcat'
d58253d155 clang-tidy: fix `performance-faster-string-find` lints
a19ec77200 clang-tidy: fix `readability-static-accessed-through-instance` lints
3d03629f20 cmWIXRichTextFormatWriter: remove identity cast
1df29567ac clang-tidy: fix `modernize-use-equals-default` lints
32fe862b8c clang-tidy: fix `readability-container-size-empty` lints
7eaab9a957 clang-tidy: fix `modernize-raw-string-literal` lints
ffa49c23aa clang-tidy: fix `readability-else-after-return` lints
4489e9a85c clang-tidy: fix `modernize-use-auto` lints
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8668
2023-08-01 09:31:45 -04:00
Brad King
241ee252ce IWYU: Update for Debian 12 CI job
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library.  Update includes
to satisfy IWYU for our CI job under Debian 12.
2023-07-28 09:14:08 -04:00
Ben Boeckel
d4144b9c0a strings: use emplace_back with cmStrCat arguments 2023-07-27 20:15:51 -04:00
Brad King
9ea7b4ac66 clang-tidy: Fix readability-redundant-string-cstr warnings 2023-05-22 17:15:58 -04:00
Joerg Bornemann
d0f49327f9 AutoMoc: Fix verbose mode message
AutoMoc generates because moc settings changed, not uic.
2023-02-07 10:59:51 -05:00
Jason Haslam
318ec07560 automoc: Remove existing output file before invoking moc
Remove the output file before invoking moc in case the case of source file has
changed on disk. Recent versions of clang warn when the case of the include
directive (which does change) doesn't match the case of the file on disk.
2022-12-04 19:56:00 -07:00
Brad King
e08d34eda1 automoc: revert attempts to silence linker warning on macos
We've made several attempts to add a dummy symbol to `mocs_compilation.cpp`
when there are no automoc sources:

* commit 4a9daae483 (automoc: silence linker warning on macos,
                     2022-05-25, v3.24.0-rc1~55^2)
* commit 844244ccdc (automoc: avoid compiler warnings in linker-warning-
                     silencing code, 2022-08-10, v3.24.1~6^2)
* commit fc8628389f (automoc: avoid more compiler warnings in linker-
                     warning-silencing code, 2022-08-29)

The last attempt derives a symbol name from the path to the source
file, but that breaks reproducible builds because it is not stable
w.r.t. the location of the build tree.  Revert all these attempts
for the 3.24 release series, and return to what 3.23 and below did.
Further investigation will be needed to resolve the original issue.

Fixes: #23937
Issue: #23551, #23823, #23823
2022-09-07 10:35:17 -04:00
Albert Astals Cid
fc8628389f automoc: avoid more compiler warnings in linker-warning-silencing code
Revise the approach from commit 844244ccdc (automoc: avoid compiler
warnings in linker-warning-silencing code, 2022-08-10, v3.24.1~6^2)
to avoid `-Wmissing-declarations` warnings too.

Issue: #23823
2022-08-30 15:21:12 -04:00
Albert Astals Cid
844244ccdc automoc: avoid compiler warnings in linker-warning-silencing code
Revise the code added by !7296 (merged).
Make cmake_automoc_silence_linker_warning less warning-y.
Fix weak-tables clang warning and copyable-polymorph clazy warning.

Fixes: #23823
2022-08-10 22:03:11 +02:00
Brad King
beb07cdda7 Source: Convince LCC that RAII variables are used
Extend the change from commit 5ad8862318 (Source: Convince NVHPC that
RAII variables are used, 2021-04-26, v3.21.0-rc1~254^2~1) to apply to
LCC too.
2022-06-13 11:07:35 -04:00
Tim Blechmann
4a9daae483 automoc: silence linker warning on macos
when an empty `mocs_compilation.cpp` is included in a static library,
the macos linker emits a warning:
```
/Applications/Xcode13.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib:
file: path/To/Library.a(mocs_compilation.cpp.o) has no symbols
```

we therefore generate a globally visible weak symbol in the form of a
virtual function table
2022-06-01 12:12:08 +08:00
Daniel Gehriger
1c9cead051 AUTOMOC: Automatically use options file for moc compiler 2022-04-26 20:43:00 +02:00
Craig Scott
2a31167955 AUTOUIC: Fix merging of --blah options not being detected for Qt6
When merging a new set of uic options with a base set of options,
such as when a source file has a non-empty AUTOUIC_OPTIONS
property, the test for whether to support options starting with
two hyphens was only testing if the Qt major version was exactly
5 rather than at least 5. That had the effect of preventing such
options from being merged correctly when using Qt6, so new and
base options would both be present instead of the single merged
option from the source file properties. Update the version check
and rename function arguments to avoid misrepresenting what
they mean.

Note that uic accepts long option names with a single hyphen too.
See Qt docs for QCommandLineParser::ParseAsLongOptions
for confirmation.
2021-10-05 23:29:16 +11:00
Sean McBride
907d098838 Source: Fix clang -Wextra-semi warnings 2021-09-28 09:59:24 -04:00
Brad King
d2a6e160aa AUTOUIC: Revert "Fix generating of dependency rules for UI header files"
Revert commit e5ec0e52f4 (AUTOUIC: Fix generating of dependency rules
for UI header files, 2021-07-22, v3.21.1~8^2) because it caused
regressions.  For example, changing one C++ source can now cause many
others to rebuild.  Revert the change pending further investigation.

Fixes: #22531
Issue: #16776
2021-08-19 12:23:16 -04:00
Alexey Edelev
e5ec0e52f4 AUTOUIC: Fix generating of dependency rules for UI header files
We could not rely on .ui files when generating the ninja rules
for the generated UI header files. .ui files might be added to the
target sources but never processed by AUTOUIC afterward, since UI
header files are never included in a source code. Instead of adding
dependency rules based on the .ui files, this approach scans
non-generated source files for includes of the UI header files,
as AUTOUIC does. This gives the consistent set of UI header files
at configure time, that could be used to generate byproducts rules
for the AUTOUIC. Also, the path to the generated UI header file depends
not on the .ui file location but on the include line is used in source
files.

Fixes: #16776
2021-07-23 15:37:31 +02:00
Alexey Edelev
9cebdbec77 AUTOUIC: Fix cyclic dependency between generated UI headers and timestamp
Once the generated UI headers are created by UIC they also are involved
into processing in next run on ninja.  Autogen adds `ui_*.h` files to
the deps file `ui_*.h` and this cause timestamp start depend on `ui_*.h`.
Meanwhile `ui_*.h` depend on timestamp because of the explicit rules
added by commit 1265c65b33 (AUTOUIC: Collect ui header files for Ninja
generator, 2021-02-18, v3.21.0-rc1~600^2).  Avoid adding `ui_*.h` to
deps file at second ninja run.

Fixes: #16776
2021-07-19 13:28:16 -04:00
Brad King
5ad8862318 Source: Convince NVHPC that RAII variables are used 2021-04-28 10:09:52 -04:00
Brad King
d00ddb9761 Merge topic 'depfile-reader-thread-safety'
53d523f2e1 autogen: fix race in depfile parsing

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6008
2021-04-16 11:35:47 -04:00
Kyle Edwards
53d523f2e1 autogen: fix race in depfile parsing
cmReadGccDepfile() calls cmSystemTools::CollapseFullPath(), which
is not thread safe due to internal caching. Serialize calls to
cmReadGccDepfile() in autogen to avoid thread safety issues.

Fixes: #22014
2021-04-15 15:25:38 -04:00
Brad King
f14e19c053 Merge topic 'ninja-automoc-cycle'
ca7c76269b Tests: Add test for Ninja automoc dependency cyle
54ad3e4958 autogen: Don't include SKIP_AUTOMOC files in depfile

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Jörg Bornemann <joerg.bornemann@qt.io>
Acked-by: Craig Scott <craig.scott@crascit.com>
Merge-request: !5956
2021-03-30 09:54:09 -04:00
Kyle Edwards
54ad3e4958 autogen: Don't include SKIP_AUTOMOC files in depfile
SKIP_AUTOMOC files should not be included in moc processing, which
means they shouldn't be included in the depfile either. Remove them.

Fixes: #21977
2021-03-29 15:17:11 -04:00
Brad King
4052aa41c5 Merge topic 'per-config-autogen-info-file'
a3df25c694 Autogen: Don't change the order of HEADERS array in AutogenInfo.json

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5840
2021-02-23 08:00:12 -05:00
Craig Scott
a3df25c694 Autogen: Don't change the order of HEADERS array in AutogenInfo.json
Qt6 reads our internal AutogenInfo.json file. In 92d7b456e5
(Autogen: Add support for per-config sources, 2020-10-20), the
ordering of the HEADERS array elements was changed and this
broke their cmake_automoc_parser. We don't need to change the
order of the array elements, we can append to the existing ones
instead. Do this to allow their cmake_automoc_parser to continue
to work.

Fixes: #21823
2021-02-22 16:11:26 +11:00
Alexey Edelev
4f577d9f3a AUTOUIC: Fix missed ui files in Ninja deps
This fixes the issue when two .ui files have the same name,
but different locations. In this case, Ninja deps file only
contains .ui file that was found first. So <src>/xxx/yyy.ui
and <src>/yyy.ui were processed as a same file by AUTOUIC.
2021-02-15 20:01:54 +01:00
Ben Boeckel
ef935b17ab clang-tidy: fix readability-use-anyofallof warnings 2021-01-27 08:54:18 -05:00
Ben Boeckel
b3b6ede6a1 clang-tidy: fix readability-redundant-access-specifiers warnings 2021-01-27 08:45:45 -05:00
Ben Boeckel
cdfc4e3195 clang-tidy: fix readability-qualified-auto warnings 2021-01-27 08:45:45 -05:00
Joerg Bornemann
8cb8dd6da5 AutoMoc: Re-run after adding Q_OBJECT macro
Consider a Qt project with a header file that does not contain the
Q_OBJECT macro. Adding the Q_OBJECT macro is supposed to trigger a run
of moc.

When using Qt >= 5.15 and the Ninja generator, re-running AutoMoc is
controlled by the contents of a Ninja depfile.  In the situation above,
AutoMoc would not re-run, because the header/source files without
Q_OBJECT macro are not contained in the depfile.

Add the relevant source files of the project to the merged depfile to
re-run AutoMoc whenever a source file changes.

Fixes: #21620
2021-01-06 20:17:20 +01:00
Oleksandr Koval
209daa20b2 Code style: add missed explicit 'this->'
CMake uses explicit 'this->' style. Using custom clang-tidy check we can
detect and fix places where 'this->' was missed.
2021-01-05 14:32:36 +02:00
Brad King
92d7b456e5 Autogen: Add support for per-config sources
Fixes: #20682
2020-12-16 14:04:30 -05:00
Kyle Edwards
946adadd40 cmGccDepfileReader: Rework helper code
Fix some of the semantics of the depfile, add error handling, and
refactor cmGccDepfileLexerHelper.
2020-10-13 10:18:02 -04:00
Joerg Bornemann
9ac3503d30 AutoMoc: Re-run moc if a dependency is missing
AutoMoc uses the moc-emitted dependency file of Qt 5.15 to track
dependencies. Such a dependency may well live outside the project and
can vanish, for example when installing a new compiler version.

This situation was detected before, but merely a warning was issued.
Now, we're considering a generated file as out of date if a dependency
is missing and re-generate it.

We also have to remove the missing dependency from the ParseCache.
Otherwise the AUTOMOC target for all generators other than Ninja will
always be out of date.

The ParseCacheChanged flag had to be made atomic, because we're
potentially accessing it from multiple threads. The dependencies vector
itself is not vulnerable in this regard, because there's one vector per
file, and we're accessing exactly one ParseCacheT::FileHandleT per thread.

Fixes: #21136
2020-09-09 12:51:28 +02:00
Brad King
776059ef0f Merge branch 'backport-3.17-automoc-depend-project-file' 2020-08-31 13:10:31 -04:00
Joerg Bornemann
6b20bbd2dd AutoMoc: Restore support for re-running after project file changes
For Qt >= 5.15.0 and Ninja generators AutoMoc creates a depfile to let
Ninja decide when to run AutoMoc.  This was introduced by commit aebfbcaa46
(AutoGen: Use depfiles for the XXX_autogen ninja targets, 2020-01-14,
v3.17.0-rc1~58^2).

However, AutoMoc was not triggered after adding a new moc-able file to
the project. This patch adds the project file (and potentially included
files) to the dependencies in the depfile.

Now, a re-run of AutoMoc is triggered if the project file changes.

Fixes: #21127
2020-08-31 13:07:23 -04:00
Brad King
9a9ed4b9d3 Merge branch 'backport-3.17-automoc_timestamp_deps' 2020-08-05 15:42:39 -04:00
Alexandru Croitor
a79056bb02 AutoGen: Fix over-specified direct dependencies of custom command
The AutoMoc timestamp creating custom command explicitly depended
on all dependencies of the origin target (associated to the AutoGen
target).

When an origin target depended on a shared library 'libfoo.so',
if it was re-linked, the AutoMoc custom command would touch its
output timestamp file, and thus cause needless rebuilding of sources,
despite the shared library not having any influence on the AutoMoc
generated files.

Introduce a new '<target>_autogen_timestamp_deps' utility target,
which will serve as an 'order-only' dependency for the custom command.

This will prevent needless rebuilding, because touching 'libfoo.so'
will not cause the custom command to be re-executed.

The new AutoMoc dependency tree looks like:
    '_autogen_timestamp_deps (serves as order-only dep)'
 <- '<target_autogen>/timestamp' file ( + moc deps file)
 <- '<target>_autogen' target.

Fixes: #21020
2020-08-03 19:38:11 +02:00
Marc Chevrier
2faa3f6c55 Refactoring: Third-parties public headers are under cm3p prefix
Fixes: #20666
2020-05-07 12:06:08 +02:00
Alex Turbov
1e4b5c7d09 Refactor: Avoid std::endl where it's not necessary (part 2)
The `std::endl` manipulator, except inserting `\n` character, also
performs `os.flush()`, which may lead to undesired effects (like
disk I/O in the middle of forming data strings). For the
`std::stringstream` it also has no meaning.

* replace multiple `operator<<` calls on a string literal w/
  the only call and the only (bigger) string literal;
* replace one character string literal used in `operator<<`
  w/ a char literal.
2020-03-24 21:32:05 +08:00
Joerg Bornemann
aebfbcaa46 AutoGen: Use depfiles for the XXX_autogen ninja targets
The XXX_autogen targets are implemented as utility commands, which
means they always run, even if there weren't any changes.

For the Ninja generator and Qt >= 5.15 we're taking a different
approach: This commit adds custom commands that create
XXX_autogen/timestamp files. Those custom commands have a depfile
assigned that is generated from the depfiles that were created by moc.

The XXX_autogen targets merely wrap the XXX_autogen/timestamp custom
commands.

Fixes: #18749
2020-01-28 11:16:11 -05:00
Joerg Bornemann
f765fdea03 AutoGen: Use moc's feature to output dependencies
In Qt version 5.15.0 moc learned to output the dependencies
of the generated file.

This commit enhances JobCompileMocT to read the dependency file
written by moc. The dependencies are stored in the same cache that's
used for the dependencies determined by dependency filters.

The dependency filter functionality is turned off if moc's dependency
output feature is used.

Fixes: #17750
Fixes: #19058
2020-01-28 11:16:11 -05:00
Marc Chevrier
f7d12609f0 Refactoring: use append functions from cmext/algorithm 2019-12-17 10:44:02 +01:00
Sebastian Holtermann
90d643c312 Autogen: Fix ambiguity in header file detection on Windows
On Windows, `CollapseFullPath` called with a path that ends with a dot
might return a file with the same base name but any extension.
To make sure we get only the file with the requested header extension,
pass the complete file name to `CollapseFullPath`.

Fixes: #19892
2019-10-30 09:34:06 -04:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Sebastian Holtermann
6bd40ccf84 Autogen: Make cmQtAutoMocUic a free function 2019-09-29 00:07:32 +02:00
Sebastian Holtermann
820962edc9 Autogen: Refactor json info file reading interface 2019-09-29 00:07:32 +02:00
Sebastian Holtermann
d867e05892 Autogen: Use JSON instead of CMake script for info files
We used to store information for the _autogen target in a CMake script
file AutogenInfo.cmake, which was imported by a temporary cmake instance in
the _autogen target.  This introduced the overhead of creating a temporary
cmake instance and inherited the limitations of the CMake language which
only supports lists.

This patch introduces JSON files to pass information to AUTORCC and
autogen_ targets.  JSON files are more flexible for passing data, e.g. they
support nested lists.

The patch has the side effects that

- AutogenInfo.cmake is renamed to AutogenInfo.json
- AutogenOldSettings.txt is renamed to AutogenUsed.txt
- RCC<qrcBaseName><checksum>Info.cmake is renamed to
  AutoRcc_<qrcBaseName>_<checksum>_Info.json
- RCC<qrcBaseName><checksum>.lock is renamed to
  AutoRcc_<qrcBaseName>_<checksum>_Lock.lock
- RCC<qrcBaseName><checksum>Settings.txt is renamed to
  AutoRcc_<qrcBaseName>_<checksum>_Used.txt
2019-09-25 10:07:09 -04:00
Marc Chevrier
c688b401d3 cmstd: Modernize CMake system headers
Provide a standardized way to handle the C++ "standard" headers
customized to be used with current CMake C++ standard constraints.
Offer under directory `cm` headers which can be used as direct
replacements of the standard ones.  For example:

    #include <cm/string_view>

can be used safely for CMake development in place of the `<string_view>`
standard header.

Fixes: #19491
2019-09-20 10:01:37 -04:00
Sebastian Holtermann
d018d27c10 Autogen: Add moc path prefix generation (AUTOMOC_PATH_PREFIX)
The new `AUTOMOC_PATH_PREFIX` boolean target property enables automatic
generation of the path prefix `-p` option for `moc`.
`AUTOMOC_PATH_PREFIX` is initialized from the variable
`CMAKE_AUTOMOC_PATH_PREFIX`, which is ON by default.

When `AUTOMOC_PATH_PREFIX` is enabled, CMake tests if a `moc`ed header file is
in one of the include directories.  If so, then the `-p` option, with the
relative path of the header parent directory to the respective include
directory, is added to the `moc` command.  If the header file is not in an
include directory, the `-p` option is omitted.

Closes: #18815 "AUTOMOC: generated files include full relative path,
                breaking certain reproducible builds"
2019-09-16 18:18:48 +02:00
Sebastian Holtermann
77983c8147 Autogen: Add IsHeader flag to SourceFileT class 2019-09-16 18:18:48 +02:00