Commit Graph

519 Commits

Author SHA1 Message Date
Ben Boeckel 09c962a6a4 Tests/CXXModules: test forced rsp files with ninja
Fixes: #25367
2023-10-27 23:55:39 -04:00
Ben Boeckel ed45432571 cmNinjaTargetGenerator: do not order-depend on C++ module sources
C++ module sources should not be included by any other TUs, so their
presence cannot matter for order-only dependencies of the entire target.
Exclude them.

Update CMP0154 to take this into consideration and add tests to the
`CXXModules` suite (which already deals with module support detection).
2023-10-20 07:18:33 -04:00
Ben Boeckel 0973cd6702 cmNinjaTargetGenerator: use the file set visibility API 2023-10-19 23:09:33 -04:00
Ben Boeckel 51f9d9f0a2 cmNinjaTargetGenerator: avoid traversing old outputs repeatedly
We actually only need to look at outputs just added to the vector, not
all outputs that have been detected so far.
2023-10-19 23:09:33 -04:00
Ben Boeckel 3cddd11649 Ninja: message about not compiled sources explicitly
With CMP0155, filesets with only non-compiled sources do not go through
the collation path that detects it. Detect it explicitly like the Visual
Studio generator does.
2023-10-02 10:17:31 -04:00
Ben Boeckel ff18acc301 CXXModules: remove EXPERIMENTAL from C++ module variable names 2023-10-02 10:17:31 -04:00
Martin Duffy ec2ba29ac5 Ninja: Allow compilation before generation of dependencies' private sources
This requires knowing when a generated header is public, which we can
model using file sets.  Add policy CMP0154 to treat generated sources
as private by default in targets with file sets.  Generated public
headers can be specified in public file sets.

Fixes: #24959
Issue: #15555
2023-09-20 10:25:24 -04:00
Brad King 0f16ebf333 cmNinjaTargetGenerator: Reduce lifetime of custom command list
Since commit 2583eff6fe (ninja: Factor out custom command order-only
depends, 2014-03-10, v3.1.0-rc1~559^2) we can store the list of custom
commands in a local variable rather than a member.
2023-09-12 15:04:15 -04:00
Ben Boeckel 9b9ec70b54 Ninja: generate scanning and build rules for C++20 module synthetic targets 2023-08-17 14:42:54 -04:00
Brad King d8b6a750a0 Merge topic 'windows-tidy-cmstrcat'
d58253d155 clang-tidy: fix `performance-faster-string-find` lints
a19ec77200 clang-tidy: fix `readability-static-accessed-through-instance` lints
3d03629f20 cmWIXRichTextFormatWriter: remove identity cast
1df29567ac clang-tidy: fix `modernize-use-equals-default` lints
32fe862b8c clang-tidy: fix `readability-container-size-empty` lints
7eaab9a957 clang-tidy: fix `modernize-raw-string-literal` lints
ffa49c23aa clang-tidy: fix `readability-else-after-return` lints
4489e9a85c clang-tidy: fix `modernize-use-auto` lints
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8668
2023-08-01 09:31:45 -04:00
Brad King 241ee252ce IWYU: Update for Debian 12 CI job
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library.  Update includes
to satisfy IWYU for our CI job under Debian 12.
2023-07-28 09:14:08 -04:00
Ben Boeckel d4144b9c0a strings: use emplace_back with cmStrCat arguments 2023-07-27 20:15:51 -04:00
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