34 Commits

Author SHA1 Message Date
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
Sebastian Holtermann
01d5e5c460 Autogen: Add and use cmQtAutoGenInitializer::InfoWriter class
The new ``cmQtAutoGenInitializer::InfoWriter`` class provides an
interface to write strings/vectors/sets/maps in CMake format
into a file.  Its use replaces various `cmJoin` calls that
failed to address escaping of semicolons in list elements.

Closes #18554
2018-11-14 19:21:03 +01:00
Sebastian Holtermann
3baa817c34 Autogen: Add support for global `autogen and autorcc` targets
This teaches CMake the variables

- CMAKE_GLOBAL_AUTOGEN_TARGET
- CMAKE_GLOBAL_AUTOGEN_TARGET_NAME
- CMAKE_GLOBAL_AUTORCC_TARGET
- CMAKE_GLOBAL_AUTORCC_TARGET_NAME

which control the generation of global
``autogen`` and ``autorcc`` targets.

Closes #17721
2018-11-11 14:28:55 +01:00
Sebastian Holtermann
b5e895b5d4 Autogen: Add (CMAKE_)AUTOGEN_ORIGIN_DEPENDS support
This adds

- the variable ``CMAKE_AUTOGEN_ORIGIN_DEPENDS`` which initializes
- the target property ``AUTOGEN_ORIGIN_DEPENDS``

which controls whether or not the origin target dependencies
should be forwarded to the corresponding ``_autogen`` target.

The default value of ``CMAKE_AUTOGEN_ORIGIN_DEPENDS`` is ``ON``
which corresponds to the behavior that is in place since CMake 3.9.

Closes: #18493
2018-11-03 12:14:40 +01:00
Sebastian Holtermann
3aa11f31fc Autogen: Use integers to store the Qt version 2018-08-13 18:12:47 +02:00
Sebastian Holtermann
1d87c9f318 Autogen: Initializer: Group variables in structs 2018-08-13 11:31:39 +02:00
Sebastian Holtermann
2d6cfe2677 Autogen: Split initializer main method 2018-07-30 09:22:47 +02:00
Sebastian Holtermann
84bdae8895 Autogen: Compute variables in Init stage instead of Setup stage 2018-07-30 09:22:46 +02:00
Sebastian Holtermann
8e0d70272d Autogen: Move info file write code into methods 2018-07-30 09:22:46 +02:00
Sebastian Holtermann
5776639fbf Autogen: Pass absolute include path in info file 2018-07-30 09:22:46 +02:00
Sebastian Holtermann
189f723509 Autogen: Wrap moc/uic/rcc related variables in structs 2018-07-11 13:54:46 +02:00
Sebastian Holtermann
c6a8002827 Autogen: Improve error detection during configuration
cmQtAutoGenInitializer::InitCustomTargets and
cmQtAutoGenInitializer::SetupCustomTargets
now return their success value which gets evaluated
and passed on by the caller (cmGlobalGenerator).

Checks for the existance of the moc/uic/rcc
binaries have been introduces in cmQtAutoGenInitializer.
Additionally they get called once with a "-h"
argument to determine if they're functional.
This way any binary-not-found problem is caught
during the configuration phase.
2018-07-11 13:29:49 +02:00
Sebastian Holtermann
e28dc3b1d8 Autogen: Add CMAKE_AUTOGEN_VERBOSE variable support
Setting CMAKE_AUTOGEN_VERBOSE enables verbose output during
AUTOMOC, AUTOUIC and AUTORCC generation.
2018-06-21 19:16:40 +02:00
Sebastian Holtermann
2930a198f6 Autogen: Add lock file to AUTORCC commands
By using a per .qrc lock file in AUTORCC, the same
`cmake -E cmake_autorcc ...` command can be called concurrently.
2018-05-30 17:45:01 +02: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
9cfa213aa6 Autogen: Rename cmQtAutogeneratorInitializer to cmQtAutoGenInitializer 2018-01-17 17:23:49 +01:00