Commit Graph

507 Commits

Author SHA1 Message Date
Ben Boeckel 677b28dc7b Ninja: include module mapper flags in compile_commands.json
Fixes: #24618
2023-07-09 11:04:29 -04:00
Ben Boeckel 6ff5cdc533 cxxmodules: remove support for CXX_MODULE_HEADER_UNITS filesets
There's no backing implementation for header units anyways, so just
remove it for now.
2023-05-31 10:57:11 -04:00
Orkun Tokdemir b480315e0c TargetGenerator: Add SKIP_LINTING source property
The `SKIP_LINTING` source property was added to disable code check for
desired source files. The `SKIP_LINTING`includes `cpplint`, `clang-tidy`, \
`cppcheck` and `include-what-you-use`. If `SKIP_LINTING` is set on a
source file, the tools mentioned above will not be run on that source file.
2023-05-16 10:47:56 -04:00
Orkun Tokdemir 993dde925f TargetGenerator: Factor out generation of code check rules
De-duplicate code check rule generation in Ninja and Makefile generators
by moving their implementation to `cmCommonTargetGenerator`.

Previously Ninja was generating code check rules per language.
It was changed to generate code check rules for each source file.
2023-05-16 10:46:35 -04:00
Brad King 1f1894af1f Ninja: Fix Fortran INCLUDE directive dependencies when not preprocessing
Since commit b0a6161190 (Fortran: Add Fortran_PREPROCESS property,
2020-04-24, v3.18.0-rc1~116^2~3), if `Fortran_PREPROCESS` is `OFF`, the
Ninja generator does not properly detect dependencies on sources loaded
via the Fortran INCLUDE directive.  Fix this and add a test.
2023-05-09 09:56:42 -04:00
Brad King 9075ebda60 Ninja: Rename internal Fortran scanner flag from --pp= to --src=
The value represents the source file to be scanned.
It is not always preprocessor output.
2023-05-09 09:56:41 -04:00
Marc Chevrier 72faa9a017 CreateRulePlaceholderExpander(): enhance memory management
This method returns now a std::unique_ptr instance rather than a raw pointer.
2023-05-04 19:34:36 +02:00
Marc Chevrier 241304190f CMake code rely on cmList class for CMake lists management (part. 2) 2023-04-29 09:54:31 +02:00
Brad King 0f6a1dd3ed Ninja: Revert "Exclude NVHPC -Werror flags during Fortran preprocessing"
Revert commit 6b58cdd4cf (Ninja: Exclude NVHPC -Werror flags during
Fortran preprocessing, 2023-04-04).  Since commit 9d40f01442 (NVHPC: Use
-Werror for COMPILE_OPTIONS_WARNING_AS_ERROR, 2023-04-13), `nvfortran`
can handle the plain `-Werror` flag during preprocessing.

Issue: #24665
2023-04-26 14:36:46 -04:00
Marc Chevrier e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Brad King 6b58cdd4cf Ninja: Exclude NVHPC -Werror flags during Fortran preprocessing
The Ninja generator preprocesses Fortran separately in order to scan for
module dependencies.  NVHPC's `nvfortran` does not support its `-Werror`
flag while preprocessing with `-E`, so filter it out.

Fixes: #24665
2023-04-04 14:53:26 -04:00
Stefan Schober 099934e313 Add generator expression support to static code analysis hooks
Teach target properties `<LANG>_CPPCHECK`, `<LANG>_CPPLINT`,
`<LANG>_CLANG_TIDY` and `<LANG>_INCLUDE_WHAT_YOU_USE` to accept
generator expressions.
2023-03-27 11:48:41 -04:00
Brad King ca8c171021 Merge topic 'clang-windows-cxx-modules'
1b7c26da49 Ninja: Wrap rules using '>' shell redirection with 'cmd /C' on Windows
ffd8537acf Clang: Record Clang 16.0 C++ modules flags only for GNU-like front-end
6013227230 cmGlobalNinjaGenerator: Use forward slashes in clang modmap format on Windows
d9d74b5e8a cmDyndepCollation: Drop outdated mentions of CXX_MODULE_INTERNAL_PARTITIONS
edab56d29a cmLocalNinjaGenerator: De-duplicate condition for using 'cmd /C' on Windows
8ebe3f92b3 cmGlobalNinjaGenerator: Detect GNU-like command-line for dyndep collator
f3ca199c9b cmGlobalNinjaGenerator: Factor out GNU-like command-line detection on Windows
f79817fcf0 cmCxxModuleMapper: Use value semantics in path conversion callback
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8346
2023-03-21 08:58:43 -04:00
Brad King 8ebe3f92b3 cmGlobalNinjaGenerator: Detect GNU-like command-line for dyndep collator
This will help the collator choose flags and path styles for modmap
files.
2023-03-18 11:52:41 -04:00
Brad King 43e973eba2 cmGeneratorTarget: Pass language to GetAppleArchs when possible 2023-03-15 10:18:41 -04:00
Brad King 93afe804ce cmGeneratorTarget: Convert GetAppleArchs output argument to return value 2023-03-15 10:11:37 -04:00
Robert Maynard 2def6a874b CUDA: Add support for CUBIN, FATBIN, and OPTIXIR compilation 2023-03-13 09:54:00 -04:00
Ben Boeckel b6a5382217 Ninja: depend on language module information files directly
Now that `GetLinkedTargetDirectories` can get the exact dependencies,
use them to simplify the collation dependency graph.
2023-02-10 18:42:02 -05:00
Ben Boeckel 0ace6053e8 Ninja: track modmap dependencies properly
Mark modmaps as outputs of the collation step.
2023-02-10 18:03:15 -05:00
Ben Boeckel b215cbc07d Ninja: remove the modmap as an output of the scanner
It's actually an output of the collator.
2023-02-10 17:51:46 -05:00
Kyle Edwards 78cf427157 RULE_LAUNCH_*: Add support for generator expressions 2023-02-03 11:23:32 -05:00
Brad King c3210aab46 Merge topic 'lang-linker-launcher-genex'
33e27f6ca6 <LANG>_LINKER_LAUNCHER: Allow generator expressions
84ada0b0c9 <LANG>_COMPILER_LAUNCHER: Expand subset of genexes that can be evaluated

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8152
2023-02-03 10:00:49 -05:00
Kyle Edwards 84ada0b0c9 <LANG>_COMPILER_LAUNCHER: Expand subset of genexes that can be evaluated 2023-02-02 11:37:30 -05:00
Ben Boeckel 837f7c113a cmCommonTargetGenerator: classify linked target directories by language
These directories are used to direct collators for Fortran and C++
modules to consume dependent module information to properly collate.
However, the consumption of these files merely checks for existence of
the file, not whether they are actually needed anymore.

The problem arises when a target has Fortran or C++ modules at point A,
a build occurs populating this file, and then the target is updated to
no longer have potential modules. The `DependInfo.make` (for
`Makefiles`) or `<LANG>DependInfo.json` (for `Ninja`) files still exist
as they are never guaranteed to be cleaned up. This can introduce stale
information to the build which may cause a false-positive compilation if
a module file happens to still exist and gets found this way.

Instead, query the `linked-target-dirs` using the language in question
and only add the directory if it contains potential sources for modules
coming from the language in question.
2023-01-31 22:34:29 -05:00
Ben Boeckel e84fcbcb0b cxxmodules: support new round of Clang patches
These patches now support the `-MF` output, so remove the `none` support
added just for the old patchset which did not use it.

Also update the flag name to `-fmodule-output=`.

Due to the new Clang module mapper flag, use a new experimental support
UUID as well.
2022-12-15 18:43:47 -05:00
Brad King 3b4337adc7 Merge topic 'clang-tidy-export-fixes-dir'
232467eb1c clang-tidy: add <LANG>_CLANG_TIDY_EXPORT_FIXES_DIR property

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7982
2022-12-07 08:19:53 -05:00
Kyle Edwards 232467eb1c clang-tidy: add <LANG>_CLANG_TIDY_EXPORT_FIXES_DIR property
Fixes: #21362
2022-12-06 10:39:29 -05:00
Ben Boeckel 9c66224668 cmNinjaTargetGenerator: skip setting depfile for none scantypes
The `clang` mechanism does not support `depfile` discovered dependencies
at the moment.
2022-12-02 13:01:13 -05:00
Ben Boeckel 9123a0991f cmNinjaTargetGenerator: use .clear() to empty out some strings 2022-12-01 22:21:42 -05:00
Ben Boeckel 3fc2de5c74 cmDyndepCollation: factor out writing C++ module info from Ninja
To facilitate other generators being able to build C++20 modules, start
pulling out collator logic into a generator-agnostic location.

This commit starts by factoring out the information written to the
"target depend info" object consumed during the build to handle writing
out export and installation scripts expected during those steps.
2022-11-30 10:53:45 -05:00
Ben Boeckel e37ff5694c cmGeneratorTarget: factor out fileset info and scanning detection 2022-11-23 18:52:36 -05:00
Ben Boeckel 9e61fc3d6d cmGeneratorTarget: factor out dyndep support detection 2022-11-23 17:35:41 -05:00
Ben Boeckel a02d792c6e cxxmodules: add properties to control scanning
The `CXX_SCAN_FOR_MODULES` property may be used to control scanning for
targets and for source files rather than assuming "C++20 always needs to
be scanned".
2022-11-18 07:54:31 -05:00
Ben Boeckel 008c09d6db cmNinjaTargetGenerator: factor out determining the fileset of a source
This information is now needed in more than one place, so factor the
logic out and use it to build a cache.
2022-11-17 15:26:55 -05:00
Brad King a9d5a0bf4b Merge topic 'compile-commands-output-field'
887a8874c3 EXPORT_COMPILE_COMMANDS: add `output` field

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7844
2022-11-01 09:02:15 -04:00
Evan Wilde e88509d0e8 Swift: Omit output-file-map when used as a linker
Swift is used as the linker for non-swift files because it needs to pull
files like swiftrt.o in when swift symbols are present to ensure that
the swift runtime is linked.

The swift driver uses clang as the underlying linker, which pulls in
crtbegin.o and friends when appropriate, so using Swift as a linker for
C/C++ libraries is fine.

The output-file-map was getting passed to all Swift invocations,
regardless of whether or not we generated one. This patch changes it so
that we only include the output-file-map in the Swift compiler
invocation if we have actually generated the file.
2022-10-28 16:44:26 -07:00
Ben Boeckel 887a8874c3 EXPORT_COMPILE_COMMANDS: add output field
Also write for all configurations from multi-config generators.

This field was added in the Clang 5 documentation and not present in the
Clang 4 documentation (sometime between Dec 2016 and Mar 2017 according
to `web.archive.org`).
2022-10-28 13:54:43 -04:00
Thomas Weißschuh 36400e9dc1 COMPILER_LAUNCHER: Add support for generator expressions
Fixes: #23441
2022-08-30 17:26:25 -04:00
Kyle Edwards a186c1aff6 Ninja Multi-Config: Deduplicate compile_commands.json for cross configs
compile_commands.json was being written for every permutation of
cross configurations. Deduplicate so only one command is output
for each configuration.

Fixes: #23733
2022-07-15 16:22:21 -04:00
Ben Boeckel fddd44c897 cmNinjaTargetGenerator: write out BMI install information for the collator 2022-07-06 10:15:23 -04:00
Ben Boeckel 95402a0bd7 cmNinjaTargetGenerator: write out export information for the collator
The collator will use this to know where the target's export information
needs to go so that module properties may be provided.
2022-07-06 10:15:23 -04:00
Ben Boeckel d3e2e61bcd cmNinjaTargetGenerator: write out fileset information for the collator
The collator will use this to generate property settings for the
imported targets in the build and install export sets.
2022-07-06 10:15:23 -04:00
Ben Boeckel 386465bf83 cmTarget: add support for C++ module fileset types
C++ modules have two variants which are of importance to CMake:

  - `CXX_MODULES`: interface modules (those using `export module M;`,
    `export module M:part;`, or `module M:internal_part;`)
  - `CXX_MODULE_HEADER_UNITS`: importable header units

Creating C++ modules or partitions are *not* supported in any other
source listing. This is because the source files must be installed (so
their scope matters), but not part of usage requirements (what it means
for a module source to be injected into a consumer is not clear at this
moment). Due to the way `FILE_SET` works with scopes, they are a perfect
fit as long as `INTERFACE` is not allowed (which it is not).
2022-06-16 10:28:34 -04:00
Ben Boeckel 030754a8b3 cmNinjaTargetGenerator: expand CFGIntDir for NMC 2022-06-14 19:27:30 -04:00
Ben Boeckel c107760417 cmNinjaTargetGenerator: support msvc-style deps discovery for scanning 2022-04-27 18:39:01 -04:00
Ben Boeckel 64c15ec018 cmNinjaTargetGenerator: add flags for scanning based on the fileset type 2022-04-27 15:14:50 -04:00
Robert Maynard f7c6b9833c CUDA: Ninja generator generates valid compile database
The ninja generator has been updated to poperly write the compile
database when the CUDA language has been enabled.

Fixes #23368
2022-03-30 15:16:43 -04:00
Peter Hill 6b4885b58b Ninja: Avoid preprocessing twice with explicit Fortran_PREPROCESS
Fix spurious warnings from gfortran+Ninja for preprocessing.

Fixes: #23248
2022-02-24 12:54:46 -05:00
Brad King 94a58e502b cmLocalGenerator: Remove unused IncludePathStyle infrastructure
It is unused since commit c564a3e3ff (Ninja: Always compile sources
using absolute paths, 2021-05-19, v3.21.0-rc1~129^2), which left
behind a FIXME comment to eventually remove it.
2021-12-01 11:33:30 -05:00
Brad King 30be83c8a2 Merge topic 'ninja-pdb-dir'
73b84db62d Ninja: Fix creation of Windows import library directory
bd36735f65 cmNinjaTargetGenerator: Replace "their" with "there" in comment

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6694
2021-11-04 09:02:02 -04:00