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

65 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
7a07887055 Autogen: Add support for response files for moc predef targets
Add support for response files for moc predef targets and make the limit when
to use response files for autogen targets configurable.
2023-11-16 16:29:02 +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
Orkun Tokdemir
cac2e029f0 cmQtAutoGenInitializer: Define CrossConfig variable 2023-09-13 15:59:54 +02:00
Cristian Adam
681714ce20 AUTOMOC: Skip PCH when all sources files skip the PCH file too
Fixes: #23464
2022-10-06 22:12:22 +02:00
Joerg Bornemann
76608c60d3 AutoMoc: Take AUTOMOC_BUILD_DIR into account in depfile
For the Ninja generator and targets that have AUTOMOC_BUILD_DIR set, the
AutoMoc target was always out of date.

That was because the depfile in the AutoMoc build directory was
referencing the wrong timestamp file:
    target_autogen/timestamp: ...dependencies...
instead of
    automoc_build_dir/timestamp: ...dependencies...

Use the relative path of the timestamp file as rule name for the
depfile.  That path is calculated with AUTOMOC_BUILD_DIR taken into
account.

Fixes: #23547
2022-05-25 13:04:01 +02: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
Joerg Bornemann
5b0ea5874a AutoGen: Retrieve Qt version from moc as fallback
Consider the case where the find_package call for QtCore is wrapped in a
function call. Then AutoGen cannot determine the Qt version, because it
only looks at variables and directory properties. The former don't leave
the function scope and the latter are not set by default.

As a fallback, locate the moc executable via its target and call it with
the --version argument to determine the Qt version.

Issue: #22028
2021-04-23 10:49:07 +02:00
Duncan Barber
a8d879cf45 Autogen: Add detection of UI file changes to the pre-build VS case
This is achieved by adding a rule file which carries the UI files as dependencies but performs no meaningful command. Its output path points to a timestamp file which is instead touched by the pre-build command that runs autogen. The rule file therefore triggers the build if any of the files have been changed more recently than the last autogen run.

Fixes: #17959
Fixes: #18741
2021-04-10 18:40:22 +01:00
Duncan Barber
1876f2d03f Autogen: Move duplicated filename generation code into a function 2021-04-10 18:33:24 +01:00
Duncan Barber
0656bebeae Autogen: Rename the variable for UI files with UIC options
Monitoring for UI file changes in the target sources will require keeping track of the files without options as well so this will improve clarity.
2021-04-10 18:33:22 +01:00
Alexey Edelev
1265c65b33 AUTOUIC: Collect ui header files for Ninja generator
The '<user target>_autogen/timestamp' target supposed to
generate ui header files using the 'uic'. Ninja must have
information about these header files as a result of generating.

The fix collects .ui files of the user target and generates
a list of the ui headers that need to be added to the generating
results of the '<user target>_autogen/timestamp' target.

The case when the .ui files are not specified and collected by
AUTOUIC from the include directives of the project source files
is not covered in this patch.

Fixes: #16776
2021-02-23 13:46:40 +01:00
Ben Boeckel
b3b6ede6a1 clang-tidy: fix readability-redundant-access-specifiers warnings 2021-01-27 08:45:45 -05:00
Brad King
92d7b456e5 Autogen: Add support for per-config sources
Fixes: #20682
2020-12-16 14:04:30 -05: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
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
Brad King
6a5a23ea92 Merge topic 'autogen_rcc_skip_unity'
086d9b2bab Autogen: Enable SKIP_UNITY_BUILD_INCLUSION on AUTORCC generated files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Cristian Adam <cristian.adam@gmail.com>
Merge-request: !4237
2020-01-20 11:54:13 -05:00
Sebastian Holtermann
086d9b2bab Autogen: Enable SKIP_UNITY_BUILD_INCLUSION on AUTORCC generated files
`rcc` generated files are not compatible with unity builds, because they
contain classes in anonymous namespaces and static data with identical names.

This patch sets the source file property `SKIP_UNITY_BUILD_INCLUSION` to `On`
on all `AUTORCC` generated files to exclude them from unity build files.

Fixes: #20191 "QT5: Exclude resource files from unity build"
2020-01-17 09:48:35 -05:00
Sebastian Holtermann
abad139c99 Autogen: Process .hh headers based on new policy CMP0100 settings
Reintroduces .hh header processing in AUTOMOC and AUTOUIC based on the new
policy CMP0100 setting.

Fixes: #13904 CMAKE_AUTOMOC misses headers with ".hh" extension
2020-01-04 11:33:04 +01: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
f54c5ee521 Autogen: Use CollapseFullPath instead of RealPath to support symbolic links 2019-09-16 18:18:48 +02:00
Sebastian Holtermann
8209691146 Autogen: Compute and store generator pointers once in initializer constructor 2019-09-16 18:18:44 +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
d02a99d9d3 Autogen: Modernize code to use cm::string_view for the info writer 2019-08-07 18:01:32 +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
4b4fd99f41 Autogen: Use ADDITIONAL_CLEAN_FILES target property for file cleaning
The `ADDITIONAL_CLEAN_FILES` target property works on multiple generators
to remove addition files at the clean target.  In `AUTOGEN` use it instead of
the deprecated and limited `ADDITIONAL_MAKE_CLEAN_FILES` directory property
to remove `AUTOGEN` generated files.

Fixes: #17074 "Autogen: clean target with ninja generator doesn’t clean
               autogen files"
2019-05-15 15:28:17 +02:00
Sebastian Holtermann
7d50e1c611 Autogen: Refactor AUTOMOC and AUTOUIC and add source file parse data caching
New features
------------

CMake's `AUTOMOC` and `AUTOUIC` now cache information extracted when parsing
source files in `CMakeFiles/<ORIGIN>_autogen.dir/ParseCache.txt`.
This leads to faster `<ORIGIN>_autogen` target rebuilds, because source files
will be parsed again only if they're newer than the `ParseCache.txt` file.
The parse cache will be recomputed if it is older than the CMake executable.

`AUTOMOC` and `AUTOUIC` now check if `moc` or `uic` output files are older
than the `moc` or `uic` executable.  If an output file is older than the
compiler, it will be regenerated.  Therefore if a new `moc` or `uic` version
is installed, all output files will be regenerated.

`AUTOMOC` and `AUTOUIC` error and warning messages are more detailed.

Internal changes
----------------

`moc` and `uic` output file names are not computed in the `_autogen`
target anymore but in `cmQtAutoGenInitializer`.  This makes the available at
the configuration stage for improved dependency computations (to be done).

In `AutogenInfo.cmake`, equally sized lists for "source file names",
"source file flags" and "compiler output file names" are passed to the
`_autogen` target.  This replaces the separate file lists for
`AUTOMOC` and `AUTOUIC`.

Files times are read from the file system only once by using `cmFileTime`
instances instead of `cmQtAutoGenerator::FileSystem::FileIsOlderThan` calls.

All calls to not thread safe file system functions are moved to non concurrent
fence jobs (see `cmWorkerPool::JobT::IsFence()`).  This renders the
`cmQtAutoGenerator::FileSystem` wrapper class obsolete and it is removed.

Instead of composing a single large settings string that is fed to the
`cmCryptoHash`, now all setting sub strings are fed one by one to the
`cmCryptoHash` and the finalized result is stored.

The `std::mutex` in `cmQtAutoGenerator::Logger` is tagged `mutable` and most
`cmQtAutoGenerator::Logger` methods become `const`.

Outlook
-------

This patch provides the framework required to

- extract dependencies from `.ui` files in `AUTOUIC`.
  These will help to address issue
  #15420 "AUTOUIC: Track uic external inputs".

- generate adaptive `make` and `ninja` files in the `_autogen` target.
  These will help to address issue
  #16776 "AUTOUIC: Ninja needs two passes to correctly build Qt project".

- generate (possibly empty) `moc` and `uic` files for all headers instead of a
  `mocs_compilation.cpp` file.
  This will help to address issue
  #17277 "AUTOMOC: Provide a option to allow AUTOMOC to compile individual "
         "moc_x.cxx instead of including all in mocs_compilation.cxx"
2019-05-07 12:42:19 +02:00
Sebastian Holtermann
521475b41b AutoRcc: Use cmQtAutoGen::RccLister in initializer and generator
Both classes `cmQtAutoGenInitializer` and `cmQtAutoGeneratorRcc` had
different implementations for reading the files list from a `.qrc` resources
file.  This patch replaces both implementations with the common simple
`cmQtAutoGen::RccLister` implementation.
2019-04-06 16:17:23 +02:00
Sebastian Holtermann
78eccc7836 Autogen: Remove lowercase generator name from generator variables class
The lowercase `Auto*` generator name in `cmQtAutoGenInitializer::GenVarsT` is
never user.  Remove it from the class.
2019-04-02 20:11:29 +02:00
Alexandru Croitor
bb97a377dd Autogen: Fallback on internal qrc parser when RCC isn't built yet
When building a Qt project, the AUTORCC functionality, by default,
uses the rcc binary to get the contents of a qrc file for
dependency information. This is done at CMake "generate" time.

The problem is that while configuring Qt itself, the rcc binary is
not built yet.
In that case, to get the contents of the qrc file, fall back to
the code branch which uses an ifstream instead of the rcc binary.
2019-03-04 12:45:16 +01: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
16c687825d Autogen: Refactor file lists computation
In AUTOGEN this replaces simple file name lists with two list (for
headers and sources) of structs with file name and file flags.
The file name lists that are passed to the _autogen target via
AutogenInfo.cmake are filtered from these two lists.
2019-02-25 08:20:19 -05:00
Sebastian Holtermann
84819c79e7 Autogen: Refactor cmQtAutoGenInitializer::AddGeneratedSource method
In AUTOGEN pass the abstract cmQtAutoGenInitializer::GenVarsT to methods
to identify the generator (moc/uic/rcc).
2019-02-21 18:27:21 +01:00
Sebastian Holtermann
d9893fb594 Autogen: Refactor Qt executable name computation
In AUTOGEN a common new  base class cmQtAutoGenInitializer::GenVarsT for
mo/uic/rcc generator variables allows to generalize variable computation
functions.
2019-02-21 18:27:10 +01:00
Sebastian Holtermann
5e36209f71 Autogen: Rename cmQtAutoGen::GeneratorT enum to cmQtAutoGen::GenT 2019-02-21 11:38:30 +01:00
Sebastian Holtermann
b5befac154 Autogen: Use output caching GetExecutableTestOutput
Use the output caching cmQtAutoGenGlobalInitializer::GetExecutableTestOutput
method to avoid identical calls to moc, uic and rcc.

Closes #18947
2019-02-19 13:11:44 -05:00
Regina Pfeifer
094f01d0f0 cleanup: Prefer compiler provided special member functions 2019-01-25 06:45:00 -05:00
Regina Pfeifer
55671b41d2 clang-tidy: Use = default
Suppress some cases in `Source/cmGeneratorExpressionNode.cxx` and
`Source/cmUVHandlePtr.h` where a few older compilers require a
user-defined default constructor (with `{}`).
2019-01-25 06:44:32 -05:00
Sebastian Holtermann
1ed4d48dcf Autogen: Prepend instead of append mocs_compilation.cpp to the sources list
`mocs_compilation.cpp` easily takes a long time to compile when it
contains multiple `moc` files.  When it was appended like before
we ran into the situation that all smaller sources were already compiled when
`mocs_compilation.cpp` got compiled at last.  In that case a single core was
busy but all remaining cores stayed idle.

To optimize CPU core utilization we now prepend `mocs_compilation.cpp`
to the sources list instead of appending it.  This allows smaller source files
to get compiled *while* the long lasting `mocs_compilation.cpp` gets compiled.

Closes #18793
2019-01-18 13:47:23 +01:00
Sebastian Holtermann
5fe18eee13 Autogen: Adaptive missing Qt warning
This makes the warning message for a missing Qt use
the requested Qt version in the message text.
2019-01-15 10:15:03 +01:00
Regina Pfeifer
b2aa3aedea clang-tidy: Use default member initialization 2018-12-15 10:52:37 +01:00
Regina Pfeifer
a2648dda97 Mark operator bool explicit 2018-11-19 23:35:09 +01:00