1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-09 15:38:15 +08:00

38 Commits

Author SHA1 Message Date
Orkun Tokdemir
7c39dabdbc Autogen: AUTO*_EXECUTABLE: add support for per-config values
* Per-config values were added to `AUTO*_EXECUTABLE`.
* Dependency order was refactored for `cmake_autogen` and `cmake_autorcc` to avoid unnecessary rebuilds.
* A new parameter was added for `cmake_autogen` and `cmake_autorcc` to specify the config name of the `auto*_executable` to be used.
* Add `AUTOGEN_BETTER_GRAPH_MULTI_CONFIG` target property to change the behavior of the dependency graph.
* The timestamp target is split into three targets for per-config to avoid redundant `mocs_compilation` builds when `AUTOGEN_BETTER_GRAPH_MULTI_CONFIG`	 is ON
* Per-config `DEP_FILE_RULE_NAME` values were added to `AutogenInfo.json` for `Multi-Config` usage.
* Some functions were refactored to avoid code duplication.

This commit reimplements fddd0f0443b4ce81d61f15ee1b2f13105967b25a

Fixes: #20074
2024-01-17 16:02:58 +01:00
tophoo
232610e60e Autogen: Use new API for limiting autogen command line lengths 2023-11-16 16:29:29 +01:00
Orkun Tokdemir
c074f5c81e Autogen: Revert "AUTO*_EXECUTABLE: add support for per-config values"
Changing the `timestamp` file to `timestamp_$<CONFIG>` causes some user
projects to break when using Qt versions older than 6.6.

Revert commit fddd0f0443 (Autogen: AUTO*_EXECUTABLE: add support for
per-config values, 2023-06-14, v3.28.0-rc1~96^2~1) pending further
investigation.

Issue: #20074
2023-10-13 14:16:26 -04:00
Orkun Tokdemir
fddd0f0443 Autogen: AUTO*_EXECUTABLE: add support for per-config values
* Per-config values were added to `AUTO*_EXECUTABLE`.
* Dependency order was refactored for `cmake_autogen` and `cmake_autorcc` to
  avoid unnecessary rebuilds.
* A new parameter was added for `cmake_autogen` and `cmake_autorcc` to specify the config name of the `auto*_executable` to be used.
* The timestamp target was split into three targets for per-config to avoid redundant `mocs_compilation` builds.
* Per-config `DEP_FILE_RULE_NAME` values were added to `AutogenInfo.json` for `CMAKE_CROSS_CONFIG` usage.
* Some functions were refactored to avoid code duplication.

Fixes: #20074
2023-09-13 18:23:56 +02: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
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
Ben Boeckel
b3b6ede6a1 clang-tidy: fix readability-redundant-access-specifiers warnings 2021-01-27 08:45:45 -05: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
Cengizhan Pasaoglu
bd705788f6 Constify some code as suggested by clang-tidy 2020-10-20 00:04:04 +03:00
Kitware Robot
bdca8b01d2 Modernize: Use #pragma once in all header files
#pragma once is a widely supported compiler pragma, even though it is
not part of the C++ standard. Many of the issues keeping #pragma once
from being standardized (distributed filesystems, build farms, hard
links, etc.) do not apply to CMake - it is easy to build CMake on a
single machine. CMake also does not install any header files which can
be consumed by other projects (though cmCPluginAPI.h has been
deliberately omitted from this conversion in case anyone is still using
it.) Finally, #pragma once has been required to build CMake since at
least August 2017 (7f29bbe6 enabled server mode unconditionally, which
had been using #pragma once since September 2016 (b13d3e0d)). The fact
that we now require C++11 filters out old compilers, and it is unlikely
that there is a compiler which supports C++11 but does not support
#pragma once.
2020-09-03 09:30:21 -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
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
Sebastian Holtermann
881e3cfbf9 Autogen: Variable renames and cleanups 2019-09-25 10:31:06 +02: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
1a3f185c1a Autogen: Split JobProbeDepsT job into separate moc and uic jobs
By splitting `JobProbeDepsT` into two independent `JobProbeDepsMocT`,
`JobProbeDepsUicT`, the moc and uic job generation will happen concurrently.
This should improve the execution speed, when both AUTOMOC and AUTOUIC are
enabled.

Parent directory names for moc and uic output files are are collected in
a `std::unordered_set<std::string>` and get created in a batch.
Beforehand we tried to create the parent directory for each output file.
This led to duplications of `MakeDirectory` calls when there were multiple
output files in the same directory (which is the case usually).
2019-09-16 18:18:48 +02:00
Regina Pfeifer
62e5f72289 clang-tidy: Replace typedef with using 2019-09-03 13:21:26 -04:00
Sebastian Holtermann
c797148e85 Autogen: Use cm::string_view for AUTO{MOC,UIC,RCC} generator names
- Store `AUTO{MOC,UIC,RCC}` generator name as `cm::string_view`
- Use `std::initializer_list` instead of `std::array`
2019-08-27 17:31:45 +02:00
Sebastian Holtermann
8586077baa Autogen: Modernize cmQtAutoGen methods using cm::string_view 2019-08-27 17:31:45 +02:00
Brad King
71fbebd1dc IWYU: Fix handling of <memory> standard header
An old workaround for `std::allocator_traits<>::value_type` lints from
IWYU on `std::vector<>` usage breaks IWYU's handling of `<memory>`.
Convert the workaround to use the same approach we already use for a
workaround of `std::__decay_and_strip<>::::__type` lints.  Then update
the `<memory>` inclusions to follow the now-correct IWYU lints.
2019-07-10 11:48:56 -04:00
Sebastian Holtermann
71d6a1455e Autogen: Evaluate compiler features for the same exectuable only once
To speed up the `AUTOGEN` configuration process, evaluate the compiler
features only once.  The feature evaluation result is stored in the new class
`cmQtAutoGen::CompilerFeatures`, and the instance is shared by using
`std::shared_ptr`.
2019-05-22 12:25:17 +02:00
Sebastian Holtermann
95de172b68 AutoRcc: Make rcc parsing function private
The `.qrc` parsing functions in `cmQtAutoGen` are no longer needed outside
the private implementation of `cmQtAutoGen::RccLister`.  This makes them
private, too.
2019-04-06 16:17:40 +02:00
Sebastian Holtermann
7cbde5c503 AutoRcc: Add cmQtAutoGen::RccLister class
The new `cmQtAutoGen::RccLister` class provides a simple interface to
list files in a `.qrc` resources file by either calling `rcc` with
list options or by parsing the resources file content.
2019-04-06 16:17:19 +02:00
Sebastian Holtermann
b32e18fb88 Autogen: Remove static const generator name strings from cmQtAutoGen 2019-04-02 20:12:43 +02:00
Sebastian Holtermann
63191b169e Autogen: Use more readable variable names for static const AUTO* strings 2019-02-26 19:33:26 +01:00
Sebastian Holtermann
5e36209f71 Autogen: Rename cmQtAutoGen::GeneratorT enum to cmQtAutoGen::GenT 2019-02-21 11:38:30 +01:00
Sebastian Holtermann
14ae19c327 Autogen: cmQtAutoGen: Store generator names in class static const strings 2019-02-21 11:37:51 +01:00
Sebastian Holtermann
f2f1661334 Autogen: Add and use QtAutoGen::Tools method 2019-01-15 09:52:35 +01:00
Sebastian Holtermann
3aa11f31fc Autogen: Use integers to store the Qt version 2018-08-13 18:12:47 +02:00
Craig Scott
8e841a473f Cleanup: Fix typos and grammar in docs and code
No functional changes, just docs, comments and error messages.
2018-04-23 07:48:03 +10:00
Sebastian Holtermann
a8ee7406a7 Autogen: Improved multi-config include scheme
For multi configuration generators AUTOMOC generates the
moc files that are included in `mocs_compilation.cpp`
in `AUTOGEN_BUILD_DIR/include_$<CONFIG>/`. By doing so each
configuration reads different moc files when compiling
`mocs_compilation.cpp`. Since we do not (need to) rewrite
`mocs_compilation.cpp` on a configuration change anymore,
the files also does not need to be recompiled anymore.
Not having to rewrite and recompile `mocs_compilation.cpp`
on a configuration change anymore was the main objective of
this patch.

In a similar fashion AUTORCC generates a `qrc_BASE_CMAKE.cpp`
file below `AUTOGEN_BUILD_DIR/include_$<CONFIG>/` and
`qrc_BASE.cpp` becomes a mere wrapper that includes this
actuall rcc output file (when using multi configuration
generators).

The template files `Modules/AutoRccInfo.cmake.in` and
`Modules/AutogenInfo.cmake.in` were removed in favor
of writing the info `.cmake` files manually.

Closes #17230
2018-02-02 09:10:40 +01:00
Sebastian Holtermann
a008578dee Autogen: Process files concurrently in AUTOMOC and AUTOUIC
This introduces concurrent thread processing in the `_autogen`
target wich processes AUTOMOC and AUTOUIC.
Source file parsing is distributed among the threads by
using a job queue from which the threads pull new parse jobs.
Each thread might start an independent ``moc`` or ``uic`` process.
Altogether this roughly speeds up the AUTOMOC and AUTOUIC build
process by the number of physical CPUs on the host system.

The exact number of threads to start in  the `_autogen` target
is controlled by the new AUTOGEN_PARALLEL target property which
is initialized by the new CMAKE_AUTOGEN_PARALLEL variable.
If AUTOGEN_PARALLEL is empty or unset (which is the default)
the thread count is set to the number of physical CPUs on
the host system.

The AUTOMOC/AUTOUIC generator and the AUTORCC generator are
refactored to use a libuv loop internally.

Closes #17422.
2018-01-17 17:23:49 +01:00
Sebastian Holtermann
ab9d5896ae Autogen: Detect rcc feature once during configuration
We used to detect the `rcc` features before every `rcc` list invocation
wich resulted in `rcc` be called twice for every listing operation.

Now we detect the `rcc` list capabilities once during configuration and
pass it to the cmake_autorcc target in the info file.
2017-11-19 13:12:42 +01:00
Sebastian Holtermann
f86ba8ee8e Autogen: Reintroduce per-config sources support
Reintroduce per-config sources support in AUTOGEN but disable it by default.
2017-09-25 16:27:38 +02:00
Sebastian Holtermann
5d3bca6485 Autogen: Rename cmQtAutoGen::GeneratorType to cmQtAutogen::Generator 2017-09-25 12:02:35 +02:00
Sebastian Holtermann
d8d064abbc Autogen: Use the same algorithm for RCC and UIC option merging 2017-09-07 17:53:19 +02:00
Sebastian Holtermann
d1e5eb8497 Autogen: Iterate source files only once
This is a large commit that serves multiple purposes

- Iterate source files only once and store all extracted
  information in a cmQtAutogenDigest class that can be reused.
  This is brings speed improvements because several properties
  are only evaluated once. More that that it helps to avoid
  duplication of code with non trivial files property checks.
- Fix the Visual Studio generator to use PRE_BUILD when possible.
- Convert `for( ... )` loops to C++11 range base loops where possible
  (cmQtAutogen*.cxx only).
- String concatenation optimizations.
2017-09-07 17:53:18 +02:00