1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-21 12:10:05 +08:00

140 Commits

Author SHA1 Message Date
Sebastian Holtermann
7d9e66a405 Ninja: Remove non cmNinjaBuild based WriteBuild method 2019-05-30 18:38:21 +02:00
Sebastian Holtermann
2dc483476c Ninja: Remove WritePhonyBuild method 2019-05-30 18:38:20 +02:00
Sebastian Holtermann
846b4b1062 Ninja: Make WriteCustomCommandBuild method use cmNinjaBuild internally 2019-05-30 18:21:36 +02:00
Sebastian Holtermann
8a46a07c8b Ninja: Make WriteMacOSXContentBuild use cmNinjaBuild internally 2019-05-30 16:44:30 +02:00
Sebastian Holtermann
15c644437a Ninja: Add cmNinjaBuild based WriteBuild (wrapper) method 2019-05-30 16:44:30 +02:00
Sebastian Holtermann
6136ab5e17 Ninja: Use cmNinjaRule as sole parameter in the WriteRule and AddRule methods
Instead of passing multiple strings to the `WriteRule` and `AddRule` methods
of `cmGlobalNinjaGenerator`, pass only a `cmNinjaRule` instance reference,
that is set up beforehand.

Adapt calls to `WriteRule` and `AddRule` in multiple places.
2019-05-29 13:04:52 +02:00
Brad King
66efdbd21a Merge topic 'additional_clean_files'
b5bf369ec6 Release notes: Add release notes for ADDITIONAL_CLEAN_FILES properties
4e2ce0a67a Doc: Update and deprecate ADDITIONAL_MAKE_CLEAN_FILES directory property
338994d65d Doc: Add documentation for ADDITIONAL_CLEAN_FILES properties
c11f089d73 Tests: Extend MakeClean test to cover ADDITIONAL_CLEAN_FILES
012d599e26 Ninja: Add support for ADDITIONAL_CLEAN_FILES target property
890a1b9dc3 Ninja: Add support for ADDITIONAL_CLEAN_FILES directory property
7b23001f20 Ninja: Add support for additional clean files
d745df4b01 Makefiles: Add support for ADDITIONAL_CLEAN_FILES target property
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3318
2019-05-15 09:22:18 -04:00
Brad King
0064edf417 Merge topic 'ninja-pool-custom-command'
9f76961de8 Support job pools in custom commands and targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3308
2019-05-15 09:21:08 -04:00
Sebastian Holtermann
7b23001f20 Ninja: Add support for additional clean files
Additional clean files for the Ninja generator can be registered
via the new method `cmGlobalNinjaGenerator::AddAdditionalCleanFile`.
If there are additional clean files, a new rule `CLEAN_ADDITIONAL` and
a new build target `CMakeFiles/clean.additional` get generated.
The `clean` target will depend on `CMakeFiles/clean.additional`, if the target
exists.
2019-05-14 17:50:14 +02:00
Rosen Matev
9f76961de8 Support job pools in custom commands and targets
Provide a way for custom commands and targets to set the pool variable
of the ninja build statement. Setting `JOB_POOL` is not compatible with
`USES_TERMINAL`, which implies the `console` pool.

The option is silently ignored with other generators.

Closes: #18483
2019-05-14 15:58:00 +02:00
Sebastian Holtermann
054954d855 Ninja: Use clean target instead of clean tool in cmake --target clean calls
A convenience `clean` target for the Ninja generator exists since commit
3bd41f2eb5.  It's safe to call `ninja clean` instead of `ninja -t clean`.
This removes the exception mapping of the `clean` target in
`cmake --build ... --target clean` calls to the Ninja `-t clean` tool.
2019-05-13 17:20:28 +02:00
Sebastian Holtermann
47da9859e8 Ninja: In cmGlobalNinjaGenerator use std::unique_ptr to manage output streams 2019-05-11 15:51:30 +02:00
Sebastian Holtermann
9902702134 Ninja: Add and use cmGlobalNinjaGenerator::CMakeCmd method 2019-05-10 20:22:26 +02:00
Sebastian Holtermann
02293841e7 Ninja: Simplify cmGlobalNinjaGenerator::AddRule and HasRule methods
- Use `std::unordered_set` for the emitted rule register
- Use `std::unordered_map` for command length register
2019-05-10 20:22:26 +02:00
Bartosz Kosiorek
324d18bb34 cmake: Teach --build mode to support multiple targets
Fixes: #16136
2019-03-05 08:55:28 -05:00
Ben Boeckel
72f9bb2993 ninja: make dyndep generation language aware
A target may have multiple languages with dyndep rules, separate `.dd`
files should be generated.
2019-02-25 10:06:20 -05:00
Brad King
f4f3b6b9af Ninja: Detect when ninja is new enough to support a multi-line depfile
Ninja 1.9 supports the multi-line depfile format generated by the
Intel Compiler for Windows.  Teach the global generator to detect
when the version is new enough to support this.
2019-01-30 14:58:21 -05:00
Brad King
d75fec5a88 Merge topic 'tidy-use-equals-default'
094f01d0f0 cleanup: Prefer compiler provided special member functions
55671b41d2 clang-tidy: Use `= default`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Brad King <brad.king@kitware.com>
Merge-request: !2841
2019-01-29 14:07:24 -05:00
Brad King
9620cb935a Merge topic 'add_consistent_verbose_build_flag'
66801f4d40 cmake: Add tests for verbose output to --build mode
439fe2e253 cmake: Add options for verbose output to --build mode
638667efa2 cmake: cmcmd.cxx fix "The arguments are" comments
3ca4402966 ctest: Fix --build-and-test without --build-target on Xcode
cb6c233ecc cmake: Add -hideShellScriptEnvironment xcodebuild option
1a45266cb5 cmGlobalGenerator: Add a class that represent the build command

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2708
2019-01-29 09:19:39 -05:00
Robert Maynard
1a45266cb5 cmGlobalGenerator: Add a class that represent the build command
This refactors a std::vector<std::string> into a class so that
we can extend the features to represent things such as multiple
chained commands in the future.
2019-01-25 08:20:02 -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
Zack Galbreath
dc6888573d Pass EXCLUDE_FROM_ALL from directory to targets
When a target is created it now inherits the EXCLUDE_FROM_ALL property
from its directory. This change makes it possible to include a target
in "all", even if its directory has been marked as EXCLUDE_FROM_ALL.
2019-01-21 11:38:24 -05:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2018-06-01 09:53:42 -04:00
Florian Maushart
1ab3881ec9 cmake: Add options for parallel builds to --build mode
While we already support `cmake --build . -- -j`, the options after `--`
are specific to the native build tool.  Add new options `--parallel
[<N>]` and `-j [<N>]` to abstract this and map to the proper option
for the native build tool.
2018-05-25 09:42:20 -04:00
Brad King
5650ba1d6a Ninja: Drop unnecessary ident encoding logic for paths
The only uses of `EncodeIdent` are surrounding `EncodePath`, but the
special ident encoding is not needed for path contexts in a ninja build
manifest.
2018-04-19 08:17:39 -04:00
Shane Parris
3f4b81f540 Add glob verify support to XCode, VS, Ninja, and Makefile generators 2018-04-01 23:16:12 -04:00
Matthias Maennich
7374cb857c Ninja: Cache ConvertToNinjaPath results to avoid repeat work
Calls to this method may dominate generation time in some cases.
Measurements for configuring cmake itself show a cache hit rate of ~57%
(7753 total calls, 4453 cache hits).  For a larger project (that also
makes use of custom targets as prerequisite for all compile targets),
the measured cache hit ratio is ~96% (2530827 total calls, 2433124 cache
hits).  For this project the observable cmake runtime could be reduced
from 40s to 30s.

Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-09-19 11:21:36 -04:00
Matthias Maennich
ed19e8136d Ninja: Improve performance with deeply-dependent custom targets
The commit v3.7.0-rc1~339^2 (Ninja: Fix inter-target order-only
dependencies of custom command, 2016-07-20) might cause performance
degradations for larger projects.  Especially when using custom
commands as an input for each compilation rule (e.g. generated headers).

For reference in the following I am referring to
  Source/cmGlobalNinjaGenerator.cxx:
    -> cmGlobalNinjaGenerator::AppendTargetDependsClosure
    -> cmGlobalNinjaGenerator::ComputeTargetDependsClosure

It turned out that the mentioned commit is doing (indirectly) some
redundant work that might impact performance when generating large
projects.

Imagine the dependency tree of custom targets:

    A
     \
      C - D - E
     /
    B

For each target the transitive closure is calculated recursively, but as
the TargetDependsClosures are only cached on the top most level, everything
downstream has to be recalculated. I.e.

    A->C->D->E
    B->C->D->E

This ultimately leads to a lot of redundant calls to AppendTargetOutputs.
The recursive nature of the algorithm itself is not significant to the
problem, but reducing the work to actually to be done work, eliminates the
performance problem.

This patch changes the way, intermediate results are cached. Rather than
caching the closure of targets, we cache the closure of outputs. Such that
in the example above at B->C the cache already would kick in.

Caching the outputs has one disadvantage that the patch takes care of.
In case of such a structure

    A       E
     \     / \
      C - D   G
     /     \ /
    B       F

the calling order for A would be

    A->C->D->E->G  (at which time G is seen to the recursion)

then the recursion returns until it reaches

    A->C->D->F     (at which the seen G would prevent to recurse down to G)

But this would poison the cache for F with a wrong value (without G).
Hence we use a local result set to ensure the cache is still consistently
populated.

For a large C++ project with around 25k targets this reduced the CMake
configure / generate time from ~40s to ~29s.

Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-09-19 11:19:34 -04:00
Brad King
0b33aee48b Use C++11 override instead of CM_OVERRIDE
We now require C++11 support including `override`.  Drop use of
the old compatibility macro.  Convert references as follows:

    git grep -l CM_OVERRIDE -- '*.h' '*.hxx' '*.cxx' |
      xargs sed -i 's/CM_OVERRIDE/override/g'
2017-09-15 10:06:41 -04:00
Daniel Pfeifer
2b4c32c95f clang-format: format all code as Cpp11 2017-08-30 11:07:05 -04:00
Daniel Pfeifer
ca2233e31f IWYU: Mark cmConfigure.h with pragma: keep
Also remove `#include "cmConfigure.h"` from most source files.
2017-08-26 07:41:04 +02:00
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
Daniel Pfeifer
b1ec5deaf1 Pass large types by const&, small types by value 2017-06-04 00:48:21 +02:00
Brad King
6a2f833563 Ninja: Fix escaping of path to depfile
Replace the dedicated and non-portable escaping code with use of our
standard escaping logic.
2017-05-30 15:30:43 -04:00
Ben Boeckel
adf60b2838 ninja: break unnecessary target dependencies
Previously, given two libraries, X and Y where X depends on Y, all
object compilations of X would require the Y library to have been linked
before being compiled. This is not necessary and can instead be loosened
such that object compilations of X only depend on the order-only
dependencies of Y to be completed. This is to ensure that generated
sources, headers, custom commands, etc. are completed before X starts to
compile its objects.

This should help build performance in projects with many libraries which
cause a deep library dependency chain. Previously, a library at the
bottom would not start compilation until after all other libraries
completed, but now only its link step needs to wait and its compilation
jobs can be run in parallel with other tasks.

Fixes: #15555
2017-04-21 08:57:40 -04:00
Daniel Pfeifer
1d829c862c Use quotes for non-system includes
Automate with:

git grep -l '#include <cm_' -- Source \
  | xargs sed -i 's/#include <\(cm_.*\)>/#include "\1"/g'

git grep -l '#include <cmsys/' -- Source \
  | xargs sed -i 's/#include <\(cmsys\/.*\)>/#include "\1"/g'

git grep -l '#include <cm[A-Z]' -- Source \
  | xargs sed -i 's/#include <\(cm[A-Z].*\)>/#include "\1"/g'
2017-04-11 22:35:21 +02:00
Ruslan Baratov
1588a577d1 Add policy CMP0069 to enforce INTERPROCEDURAL_OPTIMIZATION
Previously the `INTERPROCEDURAL_OPTIMIZATION` target property was
honored only for the Intel compiler on Linux and otherwise ignored.  In
order to add support for more compilers incrementally without changing
behavior in the future, add a new policy whose NEW behavior enforces the
`INTERPROCEDURAL_OPTIMIZATION` property.  Add flags for supported
compilers and otherwise produce an error.
2017-03-30 14:56:46 -04:00
Daniel Pfeifer
2e620f0b38 Fix several include-what-you-use findings 2016-11-08 09:42:04 -05:00
Brad King
353f6362ba Ninja: Fix POST_BUILD noop on Windows
Use `cd .` instead of `:` in a Windows shell.

Closes: #16393
2016-10-28 15:44:04 -04:00
Alexis Murzeau
e983bd326a Ninja: Use binary dir for $subdir/all targets
The targets added by commit v3.6.0-rc1~240^2~2 (Ninja: Add `$subdir/all`
targets, 2016-03-11) use as `$subdir` the relative path from the top of
the source tree to the current source directory.  This is not correct
when using `add_subdirectory(test test_bin)`.  Instead we need to use
the relative path from the top of the binary tree to the current binary
directory as was done for related targets by commit v3.7.0-rc1~268^2
(Ninja: Add `$subdir/{test,install,package}` targets, 2016-08-05).
2016-10-24 10:30:02 -04:00
Brad King
1e555a44aa Merge topic 'ninja-encoding'
ced77d2b Ninja: Use ANSI encoding for Ninja build files on Windows
2016-10-21 08:59:42 -04:00
Dāvis Mosāns
ced77d2bbd Ninja: Use ANSI encoding for Ninja build files on Windows
Pass ANSI encoding to cmGeneratedFileStream for use with Ninja
generator.
2016-10-20 13:13:48 -04:00
Brad King
2d3aa94225 cmGlobalGenerator: Allow FindMakeProgram to fail
Revise its signature to return `bool` so that it can fail and abort
configuration early.
2016-10-20 10:37:27 -04:00
Stephen Kelly
17d27893e6 cmState: Port dependent code to new cmStateDirectory name 2016-10-19 15:40:58 +02:00
Stephen Kelly
0c97806325 cmLinkLineComputer: Move ComputeLinkLibs from cmLocalGenerator
Add a cmOutputConverter to the cmLinkLineComputer and factory methods to
facilitate shell escapes.

Add state to the cmLinkLineComputer to record whether outputting for
response files or for watcom, to satisfy the cmOutputConverter API.
These are constant for the lifetime of the cmLinkLineComputer, even when
its functionality is extended in the future.  This also keeps the
signatures of cmLinkLineComputer relatively simple.

Pass the cmComputeLinkInformation as a method parameter so that
cmLinkLineComputer is free from target-specific state.  An instance
should be usable for all targets in a directory.
2016-10-10 20:38:58 +02:00
Stephen Kelly
5b361fdda0 cmLinkLineComputer: Extract from cmLocalGenerator
CMake has several classes which have too many responsibilities.
cmLocalGenerator is one of them.  Start to extract the link line
computation.  Create generator-specific implementations of the interface
to account for generator-specific behavior.

Unfortunately MSVC60 has different behavior to everything else and CMake
still generates makefiles for it.  Isolate it with MSVC60-specific
names.
2016-10-10 20:38:53 +02:00
Stephen Kelly
2e5d1990f3 Ninja: Constify 2016-10-10 20:38:53 +02:00
Brad King
86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Brad King
9a77680eed Ninja: Conditionally allow Fortran based on ninja 'dyndep' support
Detect from the version of Ninja whether it supports the dynamically
discovered dependencies (dyndep) feature needed to support Fortran.
2016-09-22 13:53:09 -04:00