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

257 Commits

Author SHA1 Message Date
Daniel Eiband
91abf9f3c4 cmCustomCommand: Move custom commands 2019-09-26 10:02:08 -04:00
Daniel Eiband
f151a57705 cmMakefile: Move enumerations into new header
The enumerations will also be used in cmLocalGenerator.
2019-09-26 10:02:06 -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
Sebastian Holtermann
fc36f4410b Autogen: Inline GetKnownQtVersions function 2019-09-25 10:31:06 +02:00
Sebastian Holtermann
1f0d23546d Autogen: Return unsigned int from GetParallelCPUCount() 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
Brad King
9c31d83aa2 Merge topic 'autogen_path_prefix'
cc0900d9cd Help: Add release notes for AUTOMOC_PATH_PREFIX
692d8e3492 Help: Add documentation for AUTOMOC_PATH_PREFIX
1933ade9f1 Tests: At QtAutogen.MocIncludeSymlink test
706d9738a6 Tests: Merge QtAutogen.MocIncludeStrict and MocIncludeRelaxed
d018d27c10 Autogen: Add moc path prefix generation (AUTOMOC_PATH_PREFIX)
77983c8147 Autogen: Add IsHeader flag to SourceFileT class
f9e5441eb4 Autogen: Abbreviate file paths in messages
51676cf655 Autogen: Split JobEvalCacheT job into separate moc and uic jobs
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3818
2019-09-19 11:19:52 -04:00
Daniel Eiband
7f3ecbe7d7 cmCustomCommandLine: Provide command line make functions
Reduce boilerplate necessary to create custom command lines by introducing and
applying cmMakeCommandLine and cmMakeSingleCommandLine functions.
2019-09-16 20:45:41 +02: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
f9e5441eb4 Autogen: Abbreviate file paths in messages
This introduces the `cmQtAutoGenerator::MessagePath` method, that abbreviates
paths by placing a
 - "SRC:" prefix in place of the project source directory
 - "BIN:" prefix in place of the project binary directory

The method is used in `AUTO{MOC,UIC,RCC}` when paths are displayed in
messages.  This makes the messages generated by `AUTO{MOC,UIC,RCC}` shorter
and improves their readability.
2019-09-16 18:18:48 +02:00
Sebastian Holtermann
05126d23f6 Autogen: Remove CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE sort duplication
This removes code that sorts include directories for `AUTOMOC` according to
`CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE`.  This is possible because the
included directories passed to `AUTOMOC` are already sorted, also with
respect to `CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE`.
2019-09-16 18:18:48 +02:00
Sebastian Holtermann
f54c5ee521 Autogen: Use CollapseFullPath instead of RealPath to support symbolic links 2019-09-16 18:18:48 +02:00
Sebastian Holtermann
65c49e0e26 Autogen: Sanitize include and search directories 2019-09-16 18:18:48 +02:00
Sebastian Holtermann
dad1a6b3fb Autogen: Modernize by using an unnamed namespace instead of static functions 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
Daniel Eiband
4fb29850ad add_custom_command: Refactor setting implicit depends
Implicit dependencies are now passed as argument to AddCustomCommandToOutput.
This is necessary to be able to delay custom command creation.
2019-09-12 23:00:36 +02:00
Brad King
de0a2354fc IWYU: Add missing cstddef includes for size_t and nullptr_t
The IWYU tool we use for CI now diagnoses these.
2019-09-03 11:46:52 -04:00
Daniel Eiband
2d888e3390 cmSourceFile: Rename mutating GetFullPath() overload
Rename mutating GetFullPath() overload to ResolveFullPath().
2019-08-29 22:51:58 +02:00
Sebastian Holtermann
da6c4b1273 Autogen: cmQtAutoGenInitializer string concatenation cleanups 2019-08-27 17:31:46 +02: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
aaf59120bf Source sweep: Replace cmExpandList with the shorter cmExpandedList
This replaces the code pattern
```
std::vector<std::string> args;
cmExpandList(valueStr, args, ...)
```
with
```
std::vector<std::string> args = cmExpandedList(valueStr, ...)
```
2019-08-23 17:07:49 +02:00
Sebastian Holtermann
9b334397f5 Source sweep: Use cmStrCat for string concatenation
This patch is generated by a python script that uses regular expressions to
search for string concatenation patterns of the kind

```
std::string str = <ARG0>;
str += <ARG1>;
str += <ARG2>;
...
```

and replaces them with a single `cmStrCat` call

```
std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...);
```

If any `<ARGX>` is itself a concatenated string of the kind

```
a + b + c + ...;
```

then `<ARGX>` is split into multiple arguments for the `cmStrCat` call.

If there's a sequence of literals in the `<ARGX>`, then all literals in the
sequence are concatenated and merged into a single literal argument for
the `cmStrCat` call.

Single character strings are converted to single char arguments for
the `cmStrCat` call.

`std::to_string(...)` wrappings are removed from `cmStrCat` arguments,
because it supports numeric types as well as string types.

`arg.substr(x)` arguments to `cmStrCat` are replaced with
`cm::string_view(arg).substr(x)`
2019-08-22 16:38:10 +02:00
Brad King
5f7386dd19 Merge topic 'string-literal-append'
da26b3be89 avoid adding multiple consecutive string literals to std::string

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3698
2019-08-19 15:06:47 -04:00
Rolf Eike Beer
da26b3be89 avoid adding multiple consecutive string literals to std::string
While at it change some single character additions to be of type char.
2019-08-18 14:22:11 +02:00
Sebastian Holtermann
20e580be01 Source sweep: Use cmIsOn instead of cmSystemTools::IsOn
This replaces invocations of

- `cmSystemTools::IsInternallyOn` with `cmIsInternallyOn`
- `cmSystemTools::IsNOTFOUND` with `cmIsNOTFOUND`
- `cmSystemTools::IsOn` with `cmIsOn`
- `cmSystemTools::IsOff` with `cmIsOff`
2019-08-17 12:14:14 +02:00
Kyle Edwards
2beed5a4ef Merge topic 'cmExpandList'
2f6495e24e cmSystemTools: Remove ExpandListArgument methods
f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument
ff42dec891 cmStringAlgorithms: Add cmExpandList functions

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3682
2019-08-16 14:51:03 -04:00
Sebastian Holtermann
f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument 2019-08-14 16:33:20 +02:00
Sebastian Holtermann
935fbe0b04 cmStringAlgorithms: Add cmStrToLong and cmStrToULong
This adds the following functions to cmStringAlgorithms:
- `cmStrToLong`: moved from `cmSystemTools::StringToLong`
- `cmStrToULong`: moved from `cmSystemTools::StringToULong`

Overloads of the given functions for `std::string` are added as well.
2019-08-10 14:39:03 +02:00
Sebastian Holtermann
ca2923110c Autogen: Modernize to use cmStrCat for string concatenation 2019-08-07 19:48:02 +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
Sebastian Holtermann
f71f7ce3f0 cmStringAlgorithms: Move string functions to the new cmStringAlgorithms.h
This adds the `cmStringAlgorithms.h` header and moves all string functions
from `cmAlgorithms.h` to `cmStringAlgorithms.h`.
2019-07-29 21:13:56 +02:00
Marc Chevrier
d9b2c7dae2 Introduce memory management helper: cm_memory.hxx 2019-07-14 15:37:30 +02:00
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