Commit Graph

90 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
Brad King dc7bed55e6 Merge topic 'cxxmodules-vs-no-synthetic-targets' into release-3.28
17fd7fe2ae Tests/CXXModules: test Visual Studio synthetic target error
badb6ab120 VS: Explicitly disallow C++ modules provided by imported targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8895
2023-10-18 09:51:52 -04:00
Ben Boeckel 17fd7fe2ae Tests/CXXModules: test Visual Studio synthetic target error 2023-10-17 14:47:18 -04:00
Ben Boeckel 0f36156740 cxxmodules: include INCLUDES DESTINATION directories
These paths are added outside the normal property management mechanisms.
Shuttle the value to the C++ module export as needed.

Fixes: #25289
2023-10-16 13:57:54 -04:00
Brad King 581a03a138 Merge topic 'cxxmodules-try_compile' into release-3.28
fd81024e80 cxxmodules: Honor CMAKE_CXX_SCAN_FOR_MODULES in try_compile

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !8865
2023-10-11 10:31:05 -04:00
Brad King 32438138c3 cxxmodules: Reference documentation in no-modules-support diagnostics
Help users avoid errors about module support when they may not need it.

While at it, polish sentence syntax in the diagnostic messages.
2023-10-11 09:52:41 -04:00
Brad King 604466b83e Tests: Enforce RunCMake.CXXModules no-modules-support diagnostics strictly
Previously the expected output expressions used `(...)*` which did not
actually have to match anything.
2023-10-11 09:44:03 -04:00
Brad King fd81024e80 cxxmodules: Honor CMAKE_CXX_SCAN_FOR_MODULES in try_compile
Under CMP0155's NEW behavior, projects that explicitly enable C++20
support with `set(CMAKE_CXX_STANDARD 20)` may also explicitly
disable scanning with `set(CMAKE_CXX_SCAN_FOR_MODULES OFF)`.
We already propagate `CMAKE_CXX_STANDARD` into `try_compile` test
projects, so propagate `CMAKE_CXX_SCAN_FOR_MODULES` too.

Fixes: #25313
2023-10-10 11:25:21 -04:00
Ben Boeckel cb7339397b Tests/RunCMake/CXXModules: remove experimental settings
Logical conflicts between the topic that introduced the tests and the
removal of the experimental flag completely.
2023-10-07 10:04:54 -04:00
Brad King b8ead378de cxxmodules: Scan only targets that explicitly enable C++ 20
Previously we scanned any targets for which C++ 20 is enabled,
even if enabled only by the compiler's default, such as when
`CXXFLAGS=-std=c++20`.
2023-10-05 13:17:00 -04:00
Brad King eb534ea5cb Tests: Modernize name of RunCMake.CXXModules compiler inspection case
We use the case name `Inspect` for similar purposes in other tests.
2023-10-04 17:14:58 -04:00
Ben Boeckel 437280b127 cxxmodules: scan C++ sources for imports by default
Existing projects are not using C++ modules in their sources,
so introduce policy CMP0155 to enable scanning by default.
2023-10-02 10:17:31 -04:00
Ben Boeckel 197a6bf171 cxxmodules: rework control logic for scanning regular C++ sources
Now that scanning support is no longer experimental, the logic for
whether or not to scan C++ 20 sources is now important because all
projects are now exposted to the logic. Make the scanning rules explicit
in the documentation and rework the queries to localize all of the
associated logic.

A policy to handle the ultimate fallback logic will be implemented in a
following commit.
2023-10-02 10:17:31 -04:00
Ben Boeckel 5eb7bd641a Tests/RunCMake/CXXModules: remove rules file requirement
Only Clang needs to disable extensions in order to work; other
implementations work as-is.
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
Ben Boeckel 0c07f39006 cmExperimental: remove the flag for C++ modules
All the major compilers now have scheduled releases with support for
scanning, so remove the experimental gate.

Fixes: #18355
2023-10-02 10:17:31 -04:00
Brad King 6bb05172ac Merge topic 'cxxmodules-export-dirs-with-prefix'
42654cc818 Tests/CXXModules: add tests for modules with include requirements
7217cb78cf Tests/CXXModules: relax line number matching in stderr
b3d1bbbbcc cmExportFileGenerator: relocate include directories for C++ modules
349ff8b080 cmGeneratorTarget: remove not-INTERFACE assertion
681a763425 cmGeneratorTarget: use a character literal

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8838
2023-09-27 11:25:22 -04:00
Ben Boeckel 42654cc818 Tests/CXXModules: add tests for modules with include requirements 2023-09-26 14:42:54 -04:00
Ben Boeckel 7217cb78cf Tests/CXXModules: relax line number matching in stderr 2023-09-26 14:42:47 -04:00
Ben Boeckel 3b632f32fa Tests/CXXModules: forward the default build type
Windows defaults the build type to `Debug` while other platforms have an
empty string.
2023-09-26 10:40:09 -04:00
Ben Boeckel 5ab6b09691 Tests/CXXModules: fix multi-config and MSVC details 2023-09-25 18:19:42 -04:00
Ben Boeckel 11b62ef118 Tests/CXXModules: add missing bmi-only and compiler id fields
Missed because the test script did not properly bubble up error reports.
2023-09-25 18:14:53 -04:00
Ben Boeckel 5d9631fbdd Tests/CXXModules: fix key set mismatch error messages 2023-09-25 18:14:53 -04:00
Ben Boeckel 86e7fb72cb Tests/CXXModules: use a less generic name for the config 2023-09-25 18:14:53 -04:00
Ben Boeckel 6b940dc590 Tests/CXXModules: replace the object extension as well 2023-09-25 18:14:53 -04:00
Ben Boeckel 1c9f83c8ec Tests/CXXModules: fix error detection propagation 2023-09-25 17:39:35 -04:00
Ben Boeckel 24a9b00f83 Merge branch 'cxxmodules-non-compiled-source-release' into cxxmodules-non-compiled-source
* cxxmodules-non-compiled-source-release:
  cxxmodules: detect and message about non-compiled sources
2023-09-12 14:47:20 -04:00
Ben Boeckel 458e3974a8 cxxmodules: detect and message about non-compiled sources
Previously an internal error was raised which ended up causing an
internal exception to be thrown. This is a typo situation that should
fall into an explicit error.

Fixes: #25207
2023-09-12 14:46:36 -04:00
Brad King 863891adb2 Merge topic 'modules-better-messages'
571b5e1f2c cxxmodules: improve error messages for C++ module setup
8b4d32c18b cmStandardLevelResolver: add query for the effective standard level
17ddc4ac76 cmStandardLevelResolver: compare with static string literals
6f1dae2b01 cmStandardLevelResolver: use `cmStrCat` where possible
0d45d40e13 cmStandardLevelResolver: use character literals where possible

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8755
2023-08-25 11:27:27 -04:00
Ben Boeckel 571b5e1f2c cxxmodules: improve error messages for C++ module setup
Make it clear that:

- the quoted string is a target name; and
- C++ sources that export modules is the important detail.
2023-08-23 16:47:29 -04:00
Ben Boeckel 48ee946fdc cmExperimental: recycle the C++ modules API UUID
Supporting modules on IMPORTED targets is worth an update.
2023-08-17 14:42:54 -04:00
Ben Boeckel 457a12f3f9 Tests/RunCMake/CXXModules: add tests which use modules from imported targets 2023-08-17 14:42:54 -04:00
Ben Boeckel 249cd3efad cmExportFileGenerator: export private compile info for C++ modules
When consuming exported targets which contain C++ modules, the consuming
project must be able to recompile BMI files using the original target's
flags. This is because a module source may use some private target usage
requirement but not want to propagate it to consumers. To facilitate
this, export the private information as necessary for consumers to be
able to perform the BMI compilations.
2023-08-17 14:42:53 -04:00
Ben Boeckel 1e9ec93f48 Tests/RunCMake/CXXModules: actually generate the source at build time
This tests what is intended to be tested (sources that do not exist
until after the configure has run).
2023-08-07 19:14:45 -04:00
Ben Boeckel be53c75852 cmExperimental: recycle the C++ modules API UUID
`try_compile` and `try_run` now support C++ modules.
2023-07-31 11:59:50 -04:00
Ben Boeckel b768d293c5 cmCoreTryCompile: use the source type context for source files
Also add a test to `RunCMake/CXXModules` to test `try_compile` with C++
modules.

Fixes: #25097
2023-07-31 11:59:47 -04:00
Brad King f8c3fd0c45 Merge topic 'dyndep-module-info-objlib-dependency'
b665966933 cmComputeLinkInformation: track OBJECT library dependencies
a99b87a628 Tests/RunCMake/CXXModules: add a test for issue #25112
2870a67540 Tests/FortranOnly: add a test case for issue #25112

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8645
2023-07-24 08:31:53 -04:00
Ben Boeckel a99b87a628 Tests/RunCMake/CXXModules: add a test for issue #25112
Add a test case for C++ `OBJECT` libraries providing modules to
consumers.
2023-07-22 06:53:38 -04:00
Ben Boeckel 57ef353d22 cmExperimental: refresh the C++ modules UUID
The transitive support for Clang is a change in support for the
ecosystem.
2023-07-13 08:40:22 -04:00
Ben Boeckel 71f1483aac Tests/RunCMake/CXXModules: require transitive usages
Clang 17 is in a transition where it warns about transitive usages. Turn
it into an error if the flag is available to make sure we're testing the
feature properly.
2023-07-13 08:40:22 -04:00
Ben Boeckel 677b28dc7b Ninja: include module mapper flags in compile_commands.json
Fixes: #24618
2023-07-09 11:04:29 -04:00
Brad King b9c99830c5 VS: Fix C++ modules in source files with the same name
When multiple source files in a single target have the same name, we
already set `ObjectFileName` explicitly to avoid a `.obj` collision. For
C++ module sources, set `Module{Output,Dependencies}File` to avoid
`.ifc` and `.module.json` collisions.

Fixes: #25038
2023-06-28 06:43:10 -04:00
Ben Boeckel 0183e1bca3 cxxmodules: remove CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP variable
It is now subsumed by the UUID setting completely.
2023-06-01 14:43:26 -04:00
Ben Boeckel 7b62a83c6f cxxmodules: update the experimental UUID
Syntactic support for C++ header units has been removed, so a new UUID
is warranted.
2023-05-31 10:57:11 -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
Tyler 28ece63fee cxxmodules: Fix exported path to installed module sources in subdirs
When generating the `IMPORTED_CXX_MODULES_[CONFIG]` target property,
there was a missing path separator after a non-empty relative directory
part of the path to a module source file.

Co-authored-by: Brad King <brad.king@kitware.com>
2023-05-23 15:01:52 -04:00
Tyler f2a699261b cxxmodules: Do not expect collator install scripts with no CXX_MODULES
Calling `install(EXPORT)` with the `CXX_MODULES_DIRECTORY` parameter
leads to installation rules being generated which `include()` CMake
scripts that set the `IMPORTED_CXX_MODULES_[CONFIG]` target property for
relevant targets.  However, these scripts don't get generated for
targets in an export set which don't have any C++20 modules.  When the
installation rules attempt to `include()` the missing scripts, the
install fails.

Co-authored-by: Brad King <brad.king@kitware.com>
2023-05-23 15:01:32 -04:00
Brad King f9677cc122 Tests: Improve RunCMake.CXXModules expectation matching and error reporting 2023-05-23 15:00:46 -04:00
Ben Boeckel 69e4525241 Tests/CXXModules: add example for private modules between targets
Adapted from the example in issue #24652 by Ivan Garramona.
2023-05-18 08:34:31 -04:00