summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.h
Commit message (Collapse)AuthorAgeFilesLines
* Ninja: Cache ConvertToNinjaPath results to avoid repeat workMatthias Maennich2017-09-191-1/+5
| | | | | | | | | | | | 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>
* Ninja: Improve performance with deeply-dependent custom targetsMatthias Maennich2017-09-191-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Use C++11 override instead of CM_OVERRIDEBrad King2017-09-151-27/+24
| | | | | | | | 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'
* clang-format: format all code as Cpp11Daniel Pfeifer2017-08-301-2/+2
|
* IWYU: Mark cmConfigure.h with pragma: keepDaniel Pfeifer2017-08-261-1/+1
| | | | Also remove `#include "cmConfigure.h"` from most source files.
* Use C++11 nullptrDaniel Pfeifer2017-08-241-1/+1
|
* Pass large types by const&, small types by valueDaniel Pfeifer2017-06-031-1/+1
|
* Ninja: Fix escaping of path to depfileBrad King2017-05-301-1/+0
| | | | | Replace the dedicated and non-portable escaping code with use of our standard escaping logic.
* ninja: break unnecessary target dependenciesBen Boeckel2017-04-211-4/+6
| | | | | | | | | | | | | | | | | | 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
* Use quotes for non-system includesDaniel Pfeifer2017-04-111-1/+1
| | | | | | | | | | | | | 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'
* Add policy CMP0069 to enforce INTERPROCEDURAL_OPTIMIZATIONRuslan Baratov2017-03-301-0/+2
| | | | | | | | | 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.
* Fix several include-what-you-use findingsDaniel Pfeifer2016-11-081-9/+13
|
* Ninja: Fix POST_BUILD noop on WindowsBrad King2016-10-281-0/+3
| | | | | | Use `cd .` instead of `:` in a Windows shell. Closes: #16393
* Ninja: Use binary dir for `$subdir/all` targetsAlexis Murzeau2016-10-241-1/+0
| | | | | | | | | | 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).
* Merge topic 'ninja-encoding'Brad King2016-10-211-0/+3
|\ | | | | | | | | ced77d2b Ninja: Use ANSI encoding for Ninja build files on Windows
| * Ninja: Use ANSI encoding for Ninja build files on WindowsDāvis Mosāns2016-10-201-0/+3
| | | | | | | | | | Pass ANSI encoding to cmGeneratedFileStream for use with Ninja generator.
* | cmGlobalGenerator: Allow FindMakeProgram to failBrad King2016-10-201-1/+1
|/ | | | | Revise its signature to return `bool` so that it can fail and abort configuration early.
* cmState: Port dependent code to new cmStateDirectory nameStephen Kelly2016-10-191-1/+1
|
* cmLinkLineComputer: Move ComputeLinkLibs from cmLocalGeneratorStephen Kelly2016-10-101-2/+3
| | | | | | | | | | | | | | | 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.
* cmLinkLineComputer: Extract from cmLocalGeneratorStephen Kelly2016-10-101-0/+3
| | | | | | | | | | | 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.
* Ninja: ConstifyStephen Kelly2016-10-101-2/+2
|
* Simplify CMake per-source license noticesBrad King2016-09-271-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Ninja: Conditionally allow Fortran based on ninja 'dyndep' supportBrad King2016-09-221-0/+1
| | | | | Detect from the version of Ninja whether it supports the dynamically discovered dependencies (dyndep) feature needed to support Fortran.
* Ninja: Add internal tool to produce a ninja dyndep file for FortranBrad King2016-09-221-0/+9
| | | | | | | Create an internal `cmake -E cmake_ninja_dyndep` tool to read the "ddi" files generated by `cmake -E cmake_ninja_depends` from all sources in a target and generate a ninja dyndep file that tells Ninja about Fortran module dependencies within the target and on target dependencies.
* Ninja: Add API to check for dyndep supportBrad King2016-09-221-0/+1
| | | | | | | Kitware maintains a branch of Ninja with support for dynamically discovered dependencies (dyndep) that has not yet been accepted upstream. Add an internal API to check whether the Ninja version in use for the build supports this feature.
* Ninja: Refactor ninja feature detectionBrad King2016-09-221-0/+3
| | | | | Check for features as soon as we know the ninja version. Save the results so we do not have to re-compare versions every time.
* Ninja: Refactor Fortran rejection logicBrad King2016-09-221-0/+2
| | | | | | | | | Delay rejection of Fortran until after we've determined the version of the `ninja` tool to be used. This will later allow us to enable Fortran support based on the version of ninja. While at it, make the rejection an immediate fatal error. Also provide a stack trace so readers know what code tried to enable Fortran.
* cmGlobalNinjaGenerator: Add API to check for implicit outputs supportBrad King2016-09-201-0/+2
| | | | | | Ninja 1.7 introduced support for implicit outputs on build statements. Add an internal API to check whether the Ninja version in use for the build supports this feature.
* cmGlobalNinjaGenerator: Teach WriteBuild about implicit outputsBrad King2016-09-201-0/+1
| | | | | | | | Ninja 1.7 introduced support for implicit outputs on build statements. Teach WriteBuild to generate the corresponding syntax. Leave it up to callers to decide whether implicit outputs are supported by the Ninja version in use. For now simply update all call sites to pass an empty list of implicit outputs.
* fix a load of include-what-you-use violationsDaniel Pfeifer2016-09-031-5/+17
|
* add_custom_command: Add DEPFILE option for NinjaKulla Christoph2016-08-301-1/+2
| | | | | | | | Provide a way for custom commands to inform the ninja build tool about their implicit dependencies. For now simply make use of the option an error on other generators. Closes: #15479
* Ninja: Fix inter-target order-only dependencies of custom commandsBrad King2016-07-201-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | Custom command dependencies are followed for each target's source files and add their transitive closure to the corresponding target. This means that when a custom command in one target has a dependency on a custom command in another target, both will appear in the dependent target's sources. For the Makefile, VS IDE, and Xcode generators this is not a problem because each target gets its own independent build system that is evaluated in target dependency order. By the time the dependent target is built the custom command that belongs to one of its dependencies will already have been brought up to date. For the Ninja generator we need to generate a monolithic build system covering all targets so we can have only one copy of a custom command. This means that we need to reconcile the target-level ordering dependencies from its appearance in multiple targets to include only the least-dependent common set. This is done by computing the set intersection of the dependencies of all the targets containing a custom command. However, we previously included only the direct dependencies so any target-level dependency not directly added to all targets into which a custom command propagates was discarded. Fix this by computing the transitive closure of dependencies for each target and then intersecting those sets. That will get the common set of dependencies. Also add a test to cover a case in which the incorrectly dropped target ordering dependencies would fail.
* CMake: Report whether generators support platformsTobias Hunger2016-07-141-0/+6
|
* use CM_NULLPTRDaniel Pfeifer2016-06-281-1/+1
|
* mark functions with CM_OVERRIDEDaniel Pfeifer2016-06-271-26/+31
|
* Ninja: Support embedding of CMake as subninja projectNicolas Despres2016-05-171-0/+5
| | | | | | Add a `CMAKE_NINJA_OUTPUT_PATH_PREFIX` variable. When it is set, CMake generates a `build.ninja` file suitable for embedding into another ninja project potentially generated by an alien generator.
* Ninja: Pass all build paths through a central methodNicolas Despres2016-05-171-0/+2
| | | | This gives us a central location to revise paths.
* Ninja: Pre-compute "CMakeCache.txt" build target nameNicolas Despres2016-05-171-0/+1
|
* Ninja: Pre-compute "all" build target nameNicolas Despres2016-05-171-0/+3
|
* Revise C++ coding style using clang-formatKitware Robot2016-05-161-100/+92
| | | | | | | | | | | | | Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * 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.
* Source: Stabilize include orderBrad King2016-04-291-4/+5
| | | | | Each source file has a logical first include file. Include it in an isolated block so that tools that sort includes do not move them.
* cmGlobalNinjaGenerator: Clarify logic for forcing use of response filesDmitry Ivanov2016-04-071-1/+1
| | | | | Update the WriteBuild method to use a negative command line length limit to specify that we should force use of response files.
* Ninja: Add `$subdir/all` targetsCharles Huet2016-03-181-0/+3
| | | | | | | | | | | | | With the Makefile generator one can use `cd $subdir; make all` to build all targets associated with a given subdirectory. This is not possible to do with the Ninja generator since there is only one `build.ninja` file at the top of the build tree. However, we can approximate it by allowing one to run `ninja $subdir/all` at the top of the tree to build the targets in the corresponding subdirectory. Port logic from cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2 to cmGlobalNinjaGenerator in order to produce equivalent directory-level targets.
* Ninja: Add 'restat' parameter to custom command generation methodBrad King2015-11-191-0/+1
| | | | Pass 'true' from all call sites to preserve existing behavior.
* cmake-gui: Add option to specify generator toolsetRobert Dailey2015-11-171-0/+6
| | | | | | | | | | The -T parameter to CMake may now be specified through cmake-gui via a new text field in the first-time configure wizard (below the generator chooser). The generator factories specify whether or not they support toolsets. This information is propagated to the Qt code and used to determine if the selected generator should also display the optional Toolset widgets.
* cmGlobalNinjaGenerator: Save 'ninja' version very earlyBrad King2015-11-021-1/+1
| | | | | Keep it in a member variable for convenient reference. Store the value as soon as it is known.
* cmGlobalNinjaGenerator: Save path to 'ninja' tool very earlyBrad King2015-11-021-1/+3
| | | | | Keep it in a member variable for convenient reference. Set the value as soon as it is known.
* Ninja: Port to cmGeneratorTarget.Stephen Kelly2015-10-241-5/+7
|
* Ninja: Centralize path conversion in global generator (#15757)Brad King2015-09-251-0/+13
| | | | | | | | | | | | | | | | | In the Ninja generator we run all build rules from the top of the build tree rather than changing into each subdirectory. Therefore we convert all paths relative to the HOME_OUTPUT directory. However, the Convert method on cmLocalGenerator restricts relative path conversions to avoid leaving the build tree with a "../" sequence. Therefore conversions performed for "subdirectories" that are outside the top of the build tree always use full paths while conversions performed for subdirectories that are inside the top of the build tree may use relative paths to refer to the same files. Since Ninja always runs rules from the top of the build tree we should convert them using only the top-level cmLocalGenerator in order to remain consistent. Also extend the test suite with a case that fails without this fix.
* cmLocalGenerator: Create from already-constructed cmMakefile.Stephen Kelly2015-08-281-1/+1
| | | | Don't manage the lifetime of the cmMakefile with cmLocalGenerator.