1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-24 13:13:18 +08:00

327 Commits

Author SHA1 Message Date
Ben Boeckel
f22c18b1c1 ninja: name dyndep internal files using the object file
Now that preprocessing outputs are not necessarily used all the way
through, the output name is a better base name to use for these files.
2019-02-25 10:14:11 -05:00
Ben Boeckel
7c78adca8e cmNinjaTargetGenerator: remove "preprocessed" mentions in dyndep
Not all languages compile the preprocessed source (or even have
preprocessed sources at all).
2019-02-25 10:14:11 -05:00
Ben Boeckel
933dd91642 ninja: do not assume explicit preprocessing uses that output
In Fortran, this is OK, but for C++, compiling preprocessed source
generally results in poorer diagnostic messages and can also be
ill-formed anyways.
2019-02-25 10:14:11 -05:00
Ben Boeckel
2c0a7bc770 ninja: pass language to cmake_ninja_depends 2019-02-25 10:14:09 -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
Saleem Abdulrasool
c048cb75fc Ninja: add properties for Swift partial module and doc
When building a swift object, we emit a partial swiftmodule and swiftdoc
that must be merged at the end.  However, in order to do that, we need
to enumerate the swiftmodules and swiftdocs.  As a result, the path must
be known to CMake.  Rather than hardcoding the rules into CMake, create
a source property that we can query.  This will allow us to create a
final placeholder to emit the merge rule.

Issue: #18800
2019-02-18 11:15:47 -08:00
Brad King
f2dc10d55c Merge topic 'ninja-swift-library-name'
157570b5a2 Add placeholder for Swift's library name

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2902
2019-02-15 10:00:21 -05:00
Brad King
0069825f50 Merge topic 'fortran-submodule-names'
d80ecba5c2 Fortran: Fix submodule file names across compilers
72057d9c15 Fortran: Thread compiler id through to internal Fortran parser
7ae329e2ed Fortran: Factor out .mod and .smod file name construction

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Michael Hirsch, Ph.D. <michael@scivision.co>
Merge-request: !2958
2019-02-14 10:25:15 -05:00
Brad King
d80ecba5c2 Fortran: Fix submodule file names across compilers
The naming convention for submodule files varies across compilers.  Add
a table to the compiler information modules and thread the information
through to the Fortran module dependency parser.  Fill out the table for
compiler ids known to support Fortran submodules.

Fixes: #18746
2019-02-14 10:23:02 -05:00
Saleem Abdulrasool
157570b5a2 Add placeholder for Swift's library name
This allows us to set the proper link name for the Swift library
(soname).  Because this needs to be passed to the object being compiled,
we need to create a new placeholder so that it can be sent along to the
frontend.  Default to the target name unless it is explicitly provided.
2019-02-13 09:25:29 -08:00
Vitaly Stakhovsky
00ba28ffd0 cmMakefile::GetRequiredDefinition: return const std::string& 2019-02-07 07:35:16 -05:00
Sebastian Holtermann
6d407ae439 Use cmSourceFile::GetIsGenerated 2019-02-01 17:02:53 +01:00
Brad King
a624a3e1b3 Ninja: Use deps=gcc for Intel Compiler on Windows
Ninja 1.9 supports the depfile format generated by this compiler.
Use `deps = gcc` when the version of Ninja is new enough.

Unfortunately the Intel Compiler for Windows does not properly
escape spaces in paths written to a depfile so if there is a
space in the path we must still fall back to `deps = msvc`.

Fixes: #18855
2019-01-30 14:59:23 -05:00
Brad King
699cd03212 Ninja: Drop unnecessary deptype customization infrastructure
Do not pass `CMAKE_NINJA_DEPTYPE_<LANG>` in place of `deps = gcc`.
If Ninja ever introduces a new dependency type we will likely need
to update CMake for it anyway.
2019-01-30 14:54:35 -05:00
Saleem Abdulrasool
de13c55d74 Ninja: support SWIFT_MODULE_NAME property
Add a new `SWIFT_MODULE_NAME` property that defaults to the target name.
This can be adjusted via `set_target_properties`.  This is needed as
otherwise, the first source file determines the module name.

Issue: #18800
2019-01-23 21:21:07 -08:00
Saleem Abdulrasool
0ffe8f8844 Ninja: support SWIFT_MODULE_NAME property
Add a new `SWIFT_MODULE_NAME` property that defaults to the target name.
This is needed as otherwise, the first source file determines the module
name.

Issue: #18800
2019-01-18 07:52:17 -05:00
Saleem Abdulrasool
b90e6134a7 Ninja: add new placeholder SWIFT_AUXILIARY_SOURCES
The swift compilation model requires all sources for the module to be
listed for the compiler to type check across them.  Provide a
placeholder to allow enumerating the remainder of the swift sources in a
target for the language compile rule.

Issue: #18800
2019-01-15 09:13:33 -08:00
Brad King
cd0881be61 IWYU: Update CMake code for IWYU built with Clang 6
IWYU now correctly requires `<utility>` for `std::move`.  It also
requires a container header when used via a range-based for loop.
2019-01-15 10:00:50 -05:00
Regina Pfeifer
32cb564bea clang-tidy: Remove redundant member initializations 2018-12-15 10:51:47 +01:00
Vitaly Stakhovsky
f4ff60a803 cmMakefile: Make GetSafeDefinition return std::string const& 2018-09-18 11:16:46 -04:00
Brad King
1b57f49586 genex: Simplify cmGeneratorExpressionInterpreter
All callers were constructing with a non-empty target name using the
target whose pointer was passed anyway.  Drop this argument.  Simplify
logic accordingly.  Re-order constructor arguments to match the
cmCompiledGeneratorExpression::Evaluate arguments.

Also remove unnecessary getters.
2018-09-07 09:23:43 -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
Marc Chevrier
cc9f88af53 LINK_DEPENDS: add support for property INTERFACE_LINK_DEPENDS
Fixes: #17997
2018-06-27 18:38:36 +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
Brad King
625b8f9076 Ninja: Avoid empty phony edges for target ordering
Since commit v3.9.0-rc1~230^2~2 (ninja: break unnecessary target
dependencies, 2017-04-17) we unconditionally generate a phony edge for
target ordering.  It is needed in case a later target depends on it.
However, if the phony edge has no inputs then `ninja -d explain` prints:

    ninja explain: output ... of phony edge with no inputs doesn't exist

Furthermore the phony edge's output is considered dirty and can cause
dependents to be incorrectly considered dirty.  Avoid this by always
generating at least one input to the target ordering phony edges.
If we have no real dependencies just use a path that always exists.

Fixes: #17942
2018-04-26 08:40:57 -04:00
Brad King
ae6722483e Merge branch 'backport-ninja-issue-17942' into ninja-issue-17942 2018-04-26 08:40:49 -04:00
Brad King
0826c20128 Ninja: Do not add empty custom command for file(GENERATE) outputs
Internally we mark `file(GENERATE)` outputs as `GENERATED` in order
to tell custom command dependency tracing logic not to expect the
files to exist on disk yet.  This is because we do not generate the
files until after that tracing is done.

The Ninja generator also interprets the `GENERATED` property to mean
that it is expected that some build rule will generate the file if
another build rule depends on it.  If the generator does not know of a
custom command that generates the file then it adds an empty one so that
the `ninja` build tool does not complain about a dependency on a file
that does not exist and has no rule to generate it.  However, this step
is not necessary for `file(GENERATE)` outputs because there is no build
rule to generate them and they will exist before `ninja` runs.

Add an additional `__CMAKE_GENERATED_BY_CMAKE` property internally to
tell the Ninja generator that a `GENERATED` file will exist before the
build starts and is not expected to have a build rule producing it.

Fixes: #17942
2018-04-26 08:39:44 -04:00
Brad King
d6390ce26e Ninja: Fix Fortran support with response files
The Ninja generator splits preprocessing and compilation steps for
Fortran.  Fix this logic to work when using response files for
compilation so that it works for the preprocessing step too.

This fixes behavior under `CMAKE_NINJA_FORCE_RESPONSE_FILE`.

Issue: #17877
2018-04-05 13:02:27 -04:00
Brad King
8592c6326b cmNinjaTargetGenerator: Move force-rspfile check to earlier 2018-04-05 12:51:21 -04:00
Brad King
e0aa060352 cmNinjaTargetGenerator: Move depfile logic to later in its function
Clarify that other compile rule generation logic does not depend on it.
2018-04-05 12:50:57 -04:00
Brad King
82de05088f Merge topic 'co-compile-with-launcher'
eaf9f69d41 Fix combined use of compiler launcher with lint tools

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1791
2018-02-28 08:17:33 -05:00
Ilya A. Kriveshko
eaf9f69d41 Fix combined use of compiler launcher with lint tools
When using ccache with clang-tidy, ccache needs to wrap compiler
invocation, rather than cmake invocation.  But it needs to do it without
affecting the command line that iwyu-like tools are receiving.

With this fix, if __run_co_compile is used, compile launcher is passed
using the new --launcher option, but if __run_co_compile is not needed,
compiler launcher is prepended to the command line as before.

To better illustrate the change: with this fix if running clang-tidy
with CXX_COMPILER_LAUNCHER set to "/usr/bin/time;-p;ccache" (time -p
added strictly for illustration purposes), the command line changes
from:

    /usr/bin/time -p ccache cmake -E __run_co_compile \
        --tidy=clang-tidy ... -- g++ ...

to:

    cmake -E __run_co_compile \
        --launcher="/usr/bin/time;-p;ccache" \
        --tidy=clang-tidy ... -- g++ ...

This allows the compiler to be run via the launcher, but leaves tidy
(& friends) invocations unaffected.

Fixes: #16493
2018-02-27 13:07:04 -05:00
Claus Klein
84de8b80ec Ninja: Use as dependency file <objectDir/SourceName>.d if needed. 2018-02-20 21:42:50 +01: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
d1d8daf15a Merge topic 'xl-qoptfile'
c4dc6485 XL: Enable use of response files for includes and objects
e342e410 Makefile,Ninja: Use tool-specific response file flag for include dirs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1691
2018-01-25 08:36:47 -05:00
Brad King
e342e4100a Makefile,Ninja: Use tool-specific response file flag for include dirs
When we use a response file for `-I` flags, not all compilers support
the `@<file>` syntax.  Define `CMAKE_<LANG>_RESPONSE_FILE_FLAG` to
specify tool-specific flag, just as we do for linking already via
`CMAKE_<LANG>_RESPONSE_FILE_LINK_FLAG`.
2018-01-24 14:31:53 -05:00
Marc Chevrier
0448311179 sourceFile properties: add property INCLUDE_DIRECTORIES 2018-01-24 15:10:10 +01:00
Marc Chevrier
78b1c2e09e sourceFile properties: add property COMPILE_OPTIONS
Add the support of per-source property COMPILE_OPTIONS,
including generator expressions support.

Related: #17507
2018-01-23 10:24:56 +01:00
Marc Chevrier
10f58b27ac Genex: Per-source $<COMPILE_LANGUAGE:...> support
Fixes: #17542
2017-12-13 16:35:22 +01:00
Marc Chevrier
9432f686e6 Add generator expression support to per-source COMPILE_DEFINITIONS
This allows users to specify different genex-based compile definitions for each file in a target.

Fixes: #17508
2017-12-05 14:47:39 +01:00
Marc Chevrier
6bffc13ef1 Refactor per-source generator expression evaluation
Prepare to add generator expression support to more source properties.
Factor out some duplicated code into a helper to avoid further
duplication.
2017-12-04 09:10:09 -05:00
Brad King
f19c70c3d2 Fortran: Add option to run the compiler through launcher tools
Add a `Fortran_COMPILER_LAUNCHER` target property like those added for C
and CXX by commit v3.4.0-rc1~450^2 (Add options to launch the compiler
through tools like ccache or distcc, 2015-06-04) and CUDA by commit
v3.10.0-rc1~531^2 (CUDA: Add option to run the compiler through launcher
tools, 2017-06-09).

Fixes: #17499
2017-11-21 14:44:01 -05:00
Brad King
068effa4d8 Merge topic 'auto_ptr'
f0489856 Retire std::auto_ptr and its macro CM_AUTO_PTR

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Pavel Solodovnikov <hellyeahdominate@gmail.com>
Merge-request: !1300
2017-09-27 07:25:11 -04: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
Brad King
df965cb963 Ninja: Fix quoting of RC language depfile in cmcldeps call
Since commit v3.0.0-rc1~448^2 (Ninja: use deps = gcc/msvc feature,
2013-10-18) the value of the `DEP_FILE` binding already includes the
needed quoting to refer to the file.  However, that commit forgot to
update one of the `$DEP_FILE` references to not be quoted anymore.
The offending code path currently only affects cmcldeps for RC.
Remove the extra quoting now.

Fixes: #17298
2017-09-25 10:07:48 -04:00
Pavel Solodovnikov
5db3aac111 Meta: replace empty-string assignments with clear(). 2017-09-16 02:26:49 +03:00
Brad King
c0c5f924fe Merge topic 'refactor-iwyu-code'
3bbe95f5 Clean up iwyu code to not be one big if statement.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1247
2017-09-15 08:54:32 -04:00
Bill Hoffman
3bbe95f58a Clean up iwyu code to not be one big if statement.
This commit changes the internal -E__run_iwyu to be -E__run_co_compile. This
is used for co-compile commands. These are tools that want to mirror the
compiler. For each compiler invocation the tool will be invoked first. This
started as a way to implement include what you use (iwyu), but has expanded
to include cpplint, cppcheck and others. Likely there will be more in the
future as well. This commit implements each one in its own function and
provides a way to add additional ones in the future with less work.
2017-09-13 17:44:49 -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