Commit Graph

436 Commits

Author SHA1 Message Date
Brad King 05f4248e3d Merge topic 'cpp-modules'
39cbbb59a5 ninja: add experimental infrastructure to generate gcc-format modmap files
791b4d26d6 ninja: add experimental infrastructure to generate modmap files with dyndep
4b23359117 ninja: Add experimental infrastructure for C++20 module dependency scanning
f814d3b3c6 cmNinjaTargetGenerator: use $OBJ_FILE for the object
b0fc2993e1 Treat the '.mpp' file extension as C++ code
988f997100 cmScanDepFormat: Fix name of our internal tool in parse errors
dacd93a2db ninja: De-duplicate version numbers required for ninja features
533386ca29 cmStandardLevelResolver: Factor out helper to capture stoi exceptions

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Acked-by: Shannon Booth <shannon.ml.booth@gmail.com>
Merge-request: !5562
2021-01-07 08:26:28 -05:00
Brad King 1cbbfbc78f Merge topic 'export-compile-commands-per-target'
a742b5d137 CMAKE_EXPORT_COMPILE_COMMANDS: allow configuration per target

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5651
2021-01-07 08:22:27 -05:00
Shannon Booth a742b5d137 CMAKE_EXPORT_COMPILE_COMMANDS: allow configuration per target
The new target property `EXPORT_COMPILE_COMMANDS` associated with the
existing global variable can be used to optionally configure targets for
their compile commands to be exported.

Fixes: #19462
2021-01-06 11:51:39 +13:00
Ben Boeckel 791b4d26d6 ninja: add experimental infrastructure to generate modmap files with dyndep
The scan step may need to output additional information for the
compiler, not just the build tool. The modmap is assumed to be beside
the object output. Additional refactoring may open up a channel to
inform per-source paths to the dyndep rule in the future, but is not
done here.
2021-01-05 09:35:10 -05:00
Brad King 4b23359117 ninja: Add experimental infrastructure for C++20 module dependency scanning
Optionally enable this infrastructure through an undocumented
`CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP` variable.  Currently this is
experimental and intended for use by compiler writers to implement their
scanning tools.  Warn as such when the feature is activated.  Later when
compilers provide the needed scanning tools we can enable this variable
from our corresponding compiler information modules.  It is never meant
to be set by project code.

When enabled, generate a build graph similar to what we use for Fortran
module dependencies.  There are some differences needed because we can
scan dependencies without explicit preprocessing, and can directly
compile the original source afterward.

Co-Author: Ben Boeckel <ben.boeckel@kitware.com>
2021-01-05 09:34:55 -05:00
Ben Boeckel f814d3b3c6 cmNinjaTargetGenerator: use $OBJ_FILE for the object
This will not be $out in all cases in the future.
2021-01-05 09:29:18 -05:00
Oleksandr Koval 209daa20b2 Code style: add missed explicit 'this->'
CMake uses explicit 'this->' style. Using custom clang-tidy check we can
detect and fix places where 'this->' was missed.
2021-01-05 14:32:36 +02:00
Brad King 67f12dd1d6 Merge topic 'ispc_control_header_suffixes'
c9a50f3556 ISPC: Generated Headers suffix configurable with a better default

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5597
2020-12-15 07:40:34 -05:00
Robert Maynard c9a50f3556 ISPC: Generated Headers suffix configurable with a better default
The target property `ISPC_HEADER_SUFFIX` and associated global
variable now can control the suffix used when generating the
C/C++ interoperability ISPC headers.

In addition the default suffix is now "_ispc.h" which matches the
common convention that the ISPC compiler team uses and recommends.
2020-12-14 13:13:09 -05:00
Brad King 60d95fe2c2 Merge topic 'correct_ispc_path_computation'
9af93fef11 ISPC: Handle OBJECT sources in different directories
72ae15ebcb ISPC: Ninja properly compute ISPC_HEADER_DIRECTORY location

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5581
2020-12-08 10:17:33 -05:00
Robert Maynard 72ae15ebcb ISPC: Ninja properly compute ISPC_HEADER_DIRECTORY location 2020-12-07 09:14:13 -05:00
Brad King 76685b985d Merge topic 'explicit-LANGUAGE-flag'
48aac247e9 Compile with explicit language flag when source LANGUAGE property is set
2e67a75acd Embarcadero: Simplify addition of -P flag for C++

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5522
2020-12-04 08:27:55 -05:00
Brad King 48aac247e9 Compile with explicit language flag when source LANGUAGE property is set
This change was originally made by commit 74b1c9fc8e (Explicitly specify
language flag when source LANGUAGE property is set, 2020-06-01,
v3.19.0-rc1~722^2), but it was reverted by commit 30aa715fac (Revert
"specify language flag when source LANGUAGE property is set",
2020-11-19) to restore compatibility with pre-3.19 behavior.

Implement the change again, but add policy CMP0119 to make this change
while preserving compatibility with existing projects.

Note that the `Compiler/{Clang,Intel,MSVC}-CXX` modules do not need to
specify `-TP` for their MSVC-like variants because we already use the
flag in `CMAKE_CXX_COMPILE_OBJECT`.  Similarly for `Compiler/XL-CXX`
and `Platform/Windows-Embarcadero`.

Note also that this does not seem possible to implement for XL C.
Even with `-qsourcetype=c`, `xlc` complains about an unknown suffix:
`1501-218 (W) file /.../AltExtC.zzz contains an incorrect file suffix`.
It returns non-zero even with `-qsuppress=1501-218`.

Co-Author: Robert Maynard <robert.maynard@kitware.com>
Fixes: #14516, #20716
2020-12-02 11:39:11 -05:00
Marc Chevrier f8d8faff8d Ninja Generators: Homogenize configuration with Makefiles
* Use same configuration variables to configure dependencies
* Abstract Ninja deps format from compiler one
2020-12-01 15:50:01 +01:00
Marc Chevrier 3401403f69 Refactoring: Introduce place-holder for dependency target.
These changes are in preparation of compiler generated dependencies support
for Makefiles generators

* compiler output and dependency target can be different for Makefiles generators
* resolve inconsistency naming for dependency file place-holder
2020-11-28 16:02:58 +01:00
Brad King 60a131efd5 Merge topic 'revert-explicit-LANGUAGE-flag'
30aa715fac Revert "specify language flag when source LANGUAGE property is set"

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5519
2020-11-20 10:05:11 -05:00
Brad King 30aa715fac Revert "specify language flag when source LANGUAGE property is set"
Revert commit 74b1c9fc8e (Explicitly specify language flag when source
LANGUAGE property is set, 2020-06-01, v3.19.0-rc1~722^2) and the lookup
tables from its two immediate ancestors.  The purpose of that change was
to convert an explicit `LANGUAGE` source file property into an explicit
language specification compiler flag like `-x c`.  This seems reasonable
since the property is documented as meaning "indicate what programming
language the source file is".  It is also needed to help compilers deal
with non-standard source file extensions they don't recognize.

However, some projects have been setting `LANGUAGE C` on `.S` assembler
source files to mean "use the C compiler".  Passing `-x c` for them
breaks the build because the `.S` sources are not written in C.  These
projects should be updated to use `enable_language(ASM)`, for which
CMake often chooses the C compiler as the assembler when using
toolchains that support it (which would have to be the case for projects
using the approach).

Revert the change for now to preserve the old behavior for such projects.
We can re-introduce it with a policy in a future version of CMake.

Fixes: #21469
Issue: #14516, #20716
2020-11-19 17:06:03 -05:00
Ben Boeckel f3eed2c49d cmGlobalNinjaGenerator: use P1689 dependency file format for Fortran
The module dependency specification format described in the C++
JTC1/SC22/WG21 paper [1] is also suitable for use by Fortran.

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1689r2.html
2020-11-17 13:17:04 -05:00
Brad King 941be1d356 cmNinjaTargetGenerator: Clarify variable names for preprocessing conditions
What is important about code paths for Fortran's explicit preprocessing
is that the compilation step following it does not do preprocessing.
2020-11-06 11:51:02 -05:00
Brad King 33a8e0bb09 cmNinjaTargetGenerator: Simplify scan rule depfile selection
The depfile can always be the first output of the build statement
with a `.d` suffix added.  This approach easily avoids conflicts.
2020-11-06 11:50:38 -05:00
Brad King bff1871c39 cmNinjaTargetGenerator: Generalize GetScanRule helper
Allow the caller to provide any number of commands, and to choose which
ones get a launcher.
2020-11-06 11:43:52 -05:00
Brad King 9f60e8aa52 cmNinjaTargetGenerator: Remove redundant conditions for dyndep blocks
The GetScanCommand and GetScanBuildStatement helpers are called only in
code paths for dyndep.  Drop their checks for this condition.
2020-11-06 11:43:52 -05:00
Brad King 43fe7e0c97 cmNinjaTargetGenerator: Revise conditions to clarify dyndep code paths
All the scan-related code paths are actually about dyndep rather than
explicit preprocessing.  It just happens that the implementation for
Fortran requires explicit preprocessing.
2020-11-06 11:43:52 -05:00
Brad King 1416012f2c cmNinjaTargetGenerator: Clarify scan rule code grouping 2020-11-06 11:43:52 -05:00
Brad King f2eec04728 cmNinjaTargetGenerator: Clarify scan rule helper functions
Revise names to clarify that these helpers are for the dependency
scanning commands, which may happen to preprocess.
2020-11-06 11:43:52 -05:00
Brad King 170cfc764d cmNinjaTargetGenerator: Drop unnecessary mutation
GetPreprocessScanRule's caller always has `vars.Source` set to `$in`.
2020-11-06 11:43:52 -05:00
Brad King fcf3fc4447 cmNinjaTargetGenerator: Clarify method names 2020-11-06 11:43:52 -05:00
Brad King fe5d0849db cmNinjaTargetGenerator: Consolidate redundant methods 2020-11-06 11:43:51 -05:00
Andrew Fuller 1134064e22 clang-tidy: allow OBJC and OBJCXX 2020-11-05 11:39:32 -08:00
vvs31415 f808f27919 cmLocalGenerator::GetRuleLauncher: return cmProp 2020-11-02 13:07:46 -05:00
Raul Tambre c63fe01835 CUDA: Clang separable compilation
For NVCC the compiler takes care of device linking when passed the "-dlink"
flag.
Clang doesn't support such magic and requires the buildsystem to do the work
that NVCC does behind the scenes.

The implementation is based on Bazel's device linking documentation:
https://github.com/tensorflow/tensorflow/blob/7cabcdf073abad8c46e9dda62bb8fa4682d2061e/third_party/nccl/build_defs.bzl.tpl#L259

Closes: #20726
2020-09-24 15:19:54 -04:00
Robert Maynard a020787a9b ISPC: Support generation for multiple instruction sets 2020-09-04 08:37:07 -04:00
Robert Maynard 5a1750017e ISPC: Add compiler launcher support 2020-09-03 11:46:11 -04:00
Vitaly Stakhovsky 11425041f0 cmMakefile::GetDefinition: return cmProp 2020-09-02 07:27:32 -04:00
Brad King f10682b796 Merge topic 'ispc_lang_support'
5ece12b7e4 gitlab-ci: add ISPC to the Fedora CI image
8976817d6d ISPC: Update help documentation to include ISPC
2368f46ba4 ISPC: Support building with the MSVC toolchain
e783bf8aa6 ISPC: Support ISPC header generation byproducts and parallel builds
34cc6acc81 Add ISPC compiler support to CMake
419d70d490 Refactor some swift only logic to be re-used by other languages

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5065
2020-09-01 09:15:39 -04:00
Robert Maynard e783bf8aa6 ISPC: Support ISPC header generation byproducts and parallel builds 2020-08-28 11:21:31 -04:00
Brad King 4391913133 Add INTERFACE libraries to generated buildsystem if they have SOURCES
INTERFACE libraries were created with the intention of collecting usage
requirements for use by other targets via `target_link_libraries`.
Therefore they were not allowed to have SOURCES and were not included in
the generated buildsystem.  In practice, this has become limiting:

* Header-only libraries do have sources, they just do not compile.
  Developers should be able to edit those sources (the header files)
  in their IDE.

* Header-only libraries may need to generate some of their header
  files via custom commands.

Some projects work around these limitations by pairing each interface
library with an `add_custom_target` that makes the header files and
custom commands appear in the generated buildsystem and in IDEs.

Lift such limitations by allowing INTERFACE libraries to have SOURCES.
For those with sources, add a corresponding build target to the
generated buildsystem.

Fixes: #19145
2020-08-07 08:46:32 -04:00
Vitaly Stakhovsky f37c14e930 Source: use cmNonempty() 2020-07-28 08:31:31 -04:00
Vitaly Stakhovsky eaad8072ee cmNonempty: Convenience inlines to check for non-empty string 2020-07-14 15:18:59 -04:00
Robert Maynard 7a969fe21d cmMakefile: Refactor API to better handle empty config values 2020-07-03 07:43:18 -04:00
Robert Maynard 74b1c9fc8e Explicitly specify language flag when source LANGUAGE property is set
Fixes: #14516, #20716
2020-06-09 19:41:20 -04:00
Brad King fff14290d2 Merge topic 'cmprop'
b36d1bdd9d Single location for cmProp typedef

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4829
2020-06-02 08:00:55 -04:00
Vitaly Stakhovsky b36d1bdd9d Single location for cmProp typedef 2020-06-01 08:54:20 -04:00
Vitaly Stakhovsky 1e805f53f5 GetDefinition: avoid duplicate calls 2020-05-29 13:12:22 -04:00
Brad King 62816ff88c Merge topic 'fortran-preprocess-property'
3888de23da Ninja: Skip Fortran preprocessing if Fortran_PREPROCESS is OFF
66c4e87282 Ninja: Add helper functions to generate Fortran build
5cca1ec893 Ninja: Add helper functions to generate Fortran preprocess rule
b0a6161190 Fortran: Add Fortran_PREPROCESS property

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4659
2020-05-22 10:35:10 -04:00
Peter Hill 3888de23da Ninja: Skip Fortran preprocessing if Fortran_PREPROCESS is OFF
If `Fortran_PREPROCESS` is explicitly turned off for a source file then
we know it does not need to be preprocessed.  Teach the Ninja generator
to skip preprocessing in this case.  Otherwise we still must preprocess
just in case.

Fixes: #18870
2020-05-21 11:46:32 -04:00
Peter Hill 66c4e87282 Ninja: Add helper functions to generate Fortran build 2020-05-21 11:45:58 -04:00
Peter Hill 5cca1ec893 Ninja: Add helper functions to generate Fortran preprocess rule 2020-05-21 11:45:58 -04:00
Peter Hill b0a6161190 Fortran: Add Fortran_PREPROCESS property
Issue: #18870
2020-05-21 11:44:14 -04:00
Cristian Adam f6cb1e646c Multi-Ninja: Fix PCHs for Visual C++
Fixes: #20711
2020-05-20 11:20:38 +02:00