Commit Graph

74 Commits

Author SHA1 Message Date
Sebastian Holtermann
4a9154537c Autogen: Use cmake::IsHeader/SourceExtension for file type detection
In the QtAutogen initializer use `cmake::IsHeaderExtension` and
`cmake::IsSourceExtension` instead of `cmSystemTools::GetFileFormat` for file
type detection.

Closes: #13904
2019-07-04 12:30:40 +02:00
Sebastian Holtermann
00e6b67e0c Autogen: Fix header detection for paths with symbolic links
When Autogen searches the header for a source files in a target,
the expanded real path is used and not the (possibly symbolic) original path
of the source file.  If the source file path contains symbolic links, then the
correct `cmSourceFile` instance of the header won't be found, but a new one
will be generated.  This way all header source file properties get lost, which
is problematic especially for the `SKIP_AUTOMOC/UIC/GEN` properties.

This patch changes the header detection in Autogen to use the original source
file path instead of the expanded real source file path.

Fixes: #19346
2019-06-06 14:14:19 -04:00
Sebastian Holtermann
b5ad572ac1 Autogen: Deprecation message for CMAKE_AUTOMOC_RELAXED_MODE
`CMAKE_AUTOMOC_RELAXED_MODE` was added for backwards compatibility with KDE 4,
which had its last release in 2014.  It does not offer additional features
but complicates the `AUTOMOC` code and dependency computation considerably.

Projects that use `CMAKE_AUTOMOC_RELAXED_MODE` functionality always got
extensive warnings during builds and tips on how to convert to regular mode,
which is trivial (see commit e474dcb231, CMake 2.8.7).

It's time to consider this feature deprecated and issue a warning at
configuration time as well.

This adds a configuration time deprecation `AUTHOR_WARNING` for
`CMAKE_AUTOMOC_RELAXED_MODE`.
2019-05-27 13:06:01 +02: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
18f7b2ed21 Autogen: Add more frequently used keywords to Keywords class 2019-04-02 20:12:52 +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
747463d1b3 Autogen: Move additional source header search to configuration stage
The computation of additional source headers and and private headers for
AUTOGEN is moved from the _autogen target to the configuration stage.  This
makes them available for _autogen target dependency computations.

Closes: #18949
2019-02-25 08:20:19 -05: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
Sebastian Holtermann
b6cf086267 Autogen: Iterate over makefile sources only once
In QtAutoGen we used to iterate over all makefile source two times to
extract file parameters for moc and uic respectively.  This patch merges both
iterations into one loop. This makes the code easier to understand and likely
faster to execute as well.
2019-02-02 18:42:08 +01:00
Sebastian Holtermann
ed0fa784eb cmSystemTools: Let GetFileFormat accept a std::stding const&
The `const char*` used formerly was converted to a `std::string`
internally anyway.
2019-02-02 18:42:08 +01:00
Sebastian Holtermann
6d407ae439 Use cmSourceFile::GetIsGenerated 2019-02-01 17:02:53 +01:00
Sebastian Holtermann
062d21c36a Autogen: Read the Qt version from directory properties as well
This lets AUTOGEN read the Qt version from directory properties as a fallback
when the Qt version variables are empty or unset.
2019-01-30 11:30:18 -05:00
Sebastian Holtermann
03dbb62d31 Autogen: Reenable passing compiler implicit include directories to moc
Since commit 5990ecb741 (Compute implicit include directories from
compiler output, 2018-12-07) we now have compiler implicit include
directory computation for gcc and clang.  It should be safe now to pass
these to `moc`.  This patch re-enables passing the compiler implicit
include directories to `moc`, which was disabled due to issue #18669.

Fixes: #18041
Issue: #18669
2019-01-28 08:41:37 -05:00
Sebastian Holtermann
f16dfdf71f cmLocalGenerator: Simplify GetIncludeDirectories
This patch strips the `stripImplicitDirs` and `appendAllImplicitDirs`
parameters from the `cmLocalGenerator::GetIncludeDirectories` method and makes
it a wrapper into the new `cmLocalGenerator::GetIncludeDirectoriesImplicit`
method.  `cmLocalGenerator::GetIncludeDirectoriesImplicit` is the renamed old
implementation of `cmLocalGenerator::GetIncludeDirectories` and still
accepts `stripImplicitDirs` and `appendAllImplicitDirs`.

The motivation is that there's only *one* case where
`cmLocalGenerator::GetIncludeDirectories` is called with the
`stripImplicitDirs` parameter being `false` (QtAutoGen), but many other places
where it is called using the `true` default value.

QtAutoGen is modified to use `cmLocalGenerator::GetIncludeDirectoriesImplicit`
directly.  In two use cases of `cmLocalGenerator::GetIncludeDirectories`
the manually set `true` value for `stripImplicitDirs` is removed.
2019-01-28 08:41:28 -05:00
Brad King
40745ad35a Merge topic 'cmake-files-directory'
3e867ed400 cmake: inlined files dir constant and removed it from cmake.h

Acked-by: Kitware Robot <kwrobot@kitware.com>
Rejected-by: vvs31415 <vstakhovsky@fastmail.com>
Merge-request: !2655
2019-01-25 08:01:26 -05:00
Vitaly Stakhovsky
99337d345b cmSystemTools::Error(): new overload accepting std::string 2019-01-23 10:19:30 -05:00
Bruno Manganelli
3e867ed400 cmake: inlined files dir constant and removed it from cmake.h 2019-01-21 15:34:16 +00:00
Brad King
1fba410ecf Merge topic 'autogen_mocs_compilation_first'
1ed4d48dcf Autogen: Prepend instead of append `mocs_compilation.cpp` to the sources list
a42b700cc2 cmTarget,cmGeneratorTarget: Add optional `before` parameter to AddSource

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Peter Wu <peter@lekensteyn.nl>
Merge-request: !2815
2019-01-21 07:53:23 -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
Regina Pfeifer
ef61997b1b clang-tidy: Use emplace 2019-01-17 13:12:02 -05:00
Brad King
e44cc45530 Merge topic 'autogen_adaptive_warning'
5fe18eee13 Autogen: Adaptive missing Qt warning
f2f1661334 Autogen: Add and use QtAutoGen::Tools method
b2343ff086 Autogen: Fix rcc validity check

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2806
2019-01-16 09:51:33 -05:00
Bruno Manganelli
cc2a5261f8 Factor out enum MessageType into dedicated header
Reduce the number of files relying on `cmake.h`.
2019-01-16 08:16:31 -05:00
Regina Pfeifer
414aa6c81e clang-tidy: Simplify boolean expressions 2019-01-15 11:40:25 -05: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
Tobias Hunger
cd32886b2f Autogen: Add AUTO(MOC|RCC|UIC)_EXECUTABLE target properties
Allow to force moc/rcc/uic compiler used for AUTO(MOC|RCC|UIC).

Setting these properties is only necessary if you are going to do
strange things like build these tools as part of your own build system.

Setting these properties will also prevent cmake from testing the
binary: It is user-provided and assumed to be valid.
2019-01-10 08:03:24 -05:00
Tobias Hunger
9045f6a30f Autogen: Prepare for Qt 6
Handle Qt version > 5 in Qt AutoGen.

This patch does *NOT* include tests and documentation: There is no
Qt 6 yet. I still need this patch to work on a cmake based build
system for Qt 6.
2019-01-07 14:13:10 +01:00
Brad King
0f7cca1dae Merge topic 'autogen-cleanups'
7630eb1975 cmQtAutoGenInitializer: Reduce code duplication

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Tobias Hunger <tobias.hunger@gmail.com>
Merge-request: !2689
2018-12-10 08:26:05 -05:00
Tobias Hunger
7630eb1975 cmQtAutoGenInitializer: Reduce code duplication
Do not repeat the code used to find uic/rcc and moc exectuables.
2018-12-07 13:44:33 -05:00
Sebastian Holtermann
4be7f38d57 Autogen: Revert passing compiler implicit includes to moc
Passing an incomplete list of compiler include directories causes
a regression in the KIO project (and probably others). We need to
disable it until the complete list is available (see #16291).

Fixes: #18669
Issue: #18041
2018-12-07 08:01:02 -05:00
Brad King
d69877fe86 Merge topic 'autogen-qtversion-detection'
5191b74524 Autogen: Qt version detection cleanup

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Sebastian Holtermann <sebholt@xwmw.org>
Merge-request: !2694
2018-12-06 09:05:22 -05:00
Brad King
a722316bcb Merge topic 'autogen_uic_empty_fix'
5f0f84c7e0 Autogen: Don't add a WIN32 moc definition if we have a moc_predefs.h file
0814d74548 Autogen: Add QtAutogen.UicNoGui test
2ef640819f Autogen: Tests: Differentiate between Qt core and Qt gui tests

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2668
2018-12-06 08:57:59 -05:00
Tobias Hunger
5191b74524 Autogen: Qt version detection cleanup
Split the Qt version detection code up a bit so that it is a bit
easier to follow.
2018-12-03 10:10:44 +01:00
Brad King
772edffbf0 Merge topic 'readability-static-accessed-through-instance'
3e60580784 clang-tidy: Fix readability-static-accessed-through-instance

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2647
2018-11-28 09:07:45 -05:00
Sebastian Holtermann
5f0f84c7e0 Autogen: Don't add a WIN32 moc definition if we have a moc_predefs.h file
On Windows systems we used to add a "-DWIN32" definition to the ``moc``
defines.  This is not necessary anymore when we have a
``moc_predefs.h`` file that provides all compiler predefines.

Closes #18623
2018-11-28 13:07:27 +01:00
Brad King
6bfcd4db3b Merge topic 'autogen_uic_empty_fix_3_13'
b1b5004c1a Autogen: Fix empty uic executable string

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2667
2018-11-28 06:42:58 -05:00
Sebastian Holtermann
b1b5004c1a Autogen: Fix empty uic executable string
In CMake 3.13.0 when a target has ``AUTOUIC`` enabled but doesn't
link against Qt5Widgets, the uic executable string is empty and
an error string "The uic executable \"\" does not exist" is generated.
In CMake 3.12 ``AUTOUIC`` was silently disabled instead.
This patch fixes the regression and restores the behavior of CMake 3.12.

Fixes: #18630
2018-11-27 08:21:40 -05:00
Regina Pfeifer
3e60580784 clang-tidy: Fix readability-static-accessed-through-instance
Enable the check in .clang-tidy and fix all warnings.
2018-11-22 00:11:37 +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
Brad King
a6e02f881d add_dependencies: Track backtraces internally
Record backtraces for "utility" dependencies created by
`add_dependencies` calls.
2018-10-18 08:10:55 -04:00
Brad King
8f076acdb0 cmLocalGenerator: Remove AddCompileDefinitions method
This method offers the same definitions as `GetTargetDefines` except
that it excludes the "export" macro on shared libraries.  Update call
sites to use `GetTargetDefines` instead.  Some of them were incorrectly
excluding the export macro.
2018-10-10 09:34:12 -04:00
Vitaly Stakhovsky
f4ff60a803 cmMakefile: Make GetSafeDefinition return std::string const& 2018-09-18 11:16:46 -04:00