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

260 Commits

Author SHA1 Message Date
Regina Pfeifer
32cb564bea clang-tidy: Remove redundant member initializations 2018-12-15 10:51:47 +01: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
Regina Pfeifer
5731ec30f0 clang-tidy: fix warnings from version 7
Fix some warnings that are new since clang-tidy version 4, and update
`.clang-tidy` to suppress the rest.
2018-11-20 10:36:08 -05:00
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03: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
ec9ef691fe Merge topic 'provide_explicit_source_and_build_command_line_options'
638f00117a Add release note for the -S and -B options.
de962cc00d CMake: Internally uses -S instead of -H to specify source directory
a10d63d578 cmake: -S and -B can be used to specify source and build directories

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2358
2018-09-19 10:38:19 -04:00
Vitaly Stakhovsky
f4ff60a803 cmMakefile: Make GetSafeDefinition return std::string const& 2018-09-18 11:16:46 -04:00
Robert Maynard
de962cc00d CMake: Internally uses -S instead of -H to specify source directory 2018-09-15 11:25:47 -04:00
Brad King
9da844d8cb Merge topic 'lg-directory'
50fbfee3a0 cmLocalGenerator: return directories as const std::string&

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2309
2018-08-28 13:43:48 -04:00
Vitaly Stakhovsky
50fbfee3a0 cmLocalGenerator: return directories as const std::string& 2018-08-27 15:48:57 -04:00
Brad King
9903ec1677 Merge topic 'ninja-generator-do-not-add-alias-matching-custom-command-output'
180c2f8de8 Ninja: Fix dupbuild error skipping alias with conflicting custom command

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Isaiah <isaiah.norton@gmail.com>
Merge-request: !2276
2018-08-27 13:57:05 -04:00
Jean-Christophe Fillion-Robin
180c2f8de8
Ninja: Fix dupbuild error skipping alias with conflicting custom command
See-also: https://issues.slicer.org/view.php?id=4595

Reported-by: Isaiah Norton <inorton@bwh.harvard.edu>
2018-08-09 13:32:23 -04:00
Sebastian Holtermann
b6802cd506 cmGeneratedFileStream: clang-tidy applied to remove redundant `c_str` calls
After changing the ``cmGeneratedFileStream`` methods to accept
``std::string const&`` instead of ``const char*`` we don't
need to call ``std::string::c_str`` anymore when passing
a ``std::string`` to a ``cmGeneratedFileStream`` method.

This patch removes all redundant ``std::string::c_str``
calls when passing a string to a ``cmGeneratedFileStream`` method.

It was generated by building CMake with clang-tidy enabled using
the following options:

-DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy-4.0;-checks=-*,readability-redundant-string-cstr;-fix;-fix-errors
2018-08-07 17:02:39 +02: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
ee44f390ce Ninja: Make assumed source dependencies order-only
Since its beginning the Ninja generator has handled `GENERATED` source
files that have no custom command producing them by writing a dummy
custom command for them that depends on the target ordering phony edge.
Make the custom command's dependency order-only since the phony edge
also has only order-only dependencies.  The dummy custom command
should never be considered "dirty" by `ninja`.

Fixes: #17942
2018-04-26 08:40:59 -04:00
Brad King
62538b2c4c Fortran: Refactor to treat .mod extension as part of module name
When tracking module names internally, include the `.mod` extension.
This will later be useful to distinguish them from `.smod` extensions
for submodules.
2018-04-20 10:56:54 -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
Shane Parris
b6ef4bc329 Document and extend the CMAKE_SUPPRESS_REGENERATION variable
Fixes: https://gitlab.kitware.com/cmake/cmake/issues/16815
2018-02-23 11:20:15 -05:00
Patrick Stewart
ed000d7d30 Ninja: Don't add custom command outputs to phony rule for CMake inputs 2018-02-15 15:03:53 +00:00
Pavel Solodovnikov
653b894683 Reduce raw string pointers usage.
* Change some functions to take `std::string` instead of
  `const char*` in the following classes: `cmMakeFile`, `cmake`,
  `cmCoreTryCompile`, `cmSystemTools`,  `cmState`, `cmLocalGenerator`
  and a few others.
* Greatly reduce using of `const char*` overloads for
  `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`.
* Remove many redundant `c_str()` conversions throughout the code.
2018-01-31 18:23:03 +03:00
Pavel Solodovnikov
c85bb007df Reduce allocation of temporary values on heap.
- Use `std::move` while inserting temporary results into vectors.
- Change `push_back` to `emplace_back` where appropriate.
2018-01-26 13:24:45 +03:00
Brad King
05af537ecc cmGlobalNinjaGenerator: Avoid using deprecated std::ptr_fun
It was deprecated by C++11 and removed by C++17.  Use a C++11 lambda.
2017-12-21 08:05:23 -05:00
Matthias Maennich
f0489856e3 Retire std::auto_ptr and its macro CM_AUTO_PTR
Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-09-26 00:07:19 +02: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
Pavel Solodovnikov
7d5095796a Meta: modernize old-fashioned loops to range-based for.
Changes done via `clang-tidy` with some manual fine-tuning
for the variable naming and `auto` type deduction
where appropriate.
2017-09-12 16:22:47 +03:00
Daniel Pfeifer
2b4c32c95f clang-format: format all code as Cpp11 2017-08-30 11:07:05 -04:00
Daniel Pfeifer
190e3825d4 Replace C-style casts 2017-08-27 09:58:46 +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
82badfffc3 Ninja: Fix CMP0058 on MinGW
For CMP0058 we identify dependencies that have no rules to generate them
by collecting a set of all dependencies and a set of all files CMake
knows are generated by something, and then computing a set difference.
Fix construction of these sets to use the same form for each path.
This is after ConvertToNinjaPath but before EncodePath.

Without this, the slash conversion done by EncodePath for the GNU
compiler on Windows results in a mismatch, triggering an incorrect
CMP0058 warning.
2017-05-31 13:44:16 -04: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
Pavel Solodovnikov
2c2bb5f527 Remove unnecessary operator<< usage 2017-05-26 19:54:29 +03:00
Kevin Puetz
b554caf753 Ninja: List compile_commands.json as generated by CMake
This fixes a false-positive `CMP0058` warning if any custom rules depend
on `compile_commands.json` (e.g. to trigger rerunning clang-tooling
utilities).

Fixes: #16444
2017-05-16 10:21:22 -04:00
Daniel Pfeifer
c36d63cd48 cmake: initialize with Role that controls which commands to register 2017-05-08 22:29:44 +02:00
Brad King
74672e2ffa Merge topic 'ninja-dyndep-response-file'
594d3d6f Ninja: support response file for cmake_ninja_depends on Windows

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !722
2017-04-25 09:41:18 -04:00
Bernhard Burgermeister
594d3d6fff Ninja: support response file for cmake_ninja_depends on Windows
The internal tool "cmake_ninja_depends" now supports reading the list of ddi
files from a reponse file to circumvent Windows command line length limits.

Use this response file for dyndep rule on Windows.
2017-04-25 09:32:50 +02: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
Brad King
5b241d0ae8 Merge topic '16760-refactor-get-mac-content-directory'
cf320f7c Replace boolean `implib` parameters with enum

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !662
2017-04-21 08:53:16 -04:00
Gregor Jasny
cf320f7cd7 Replace boolean implib parameters with enum
Named enumeration values are much clearer at call sites and add more
type safety.
2017-04-20 10:22:33 -04:00
Christian Pfeiffer
bbb5c3efe2 Ninja,Makefile: Unify command line limit logic
Move the logic to cmSystemTools to be shared among the generators.
Revise the implementation and add comments justifying each possible
source for a limit.
2017-04-19 11:02:24 -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
Brad King
666bb0e3fa Merge topic 'include-what-you-use'
2e620f0b Fix several include-what-you-use findings
2016-11-08 09:44:40 -05:00
Daniel Pfeifer
2e620f0b38 Fix several include-what-you-use findings 2016-11-08 09:42:04 -05:00
Daniel Pfeifer
1e994985d8 cmGlobalNinjaGenerator: Suppress clang-tidy warning 2016-11-05 23:51:30 +01: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