From badb6ab120bb3bb01c6b41e50aadb234d16e8e21 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 16 Oct 2023 15:42:21 -0400 Subject: VS: Explicitly disallow C++ modules provided by imported targets The `-ifcOnly` flag is understood by MSBuild, but there are unresolved questions about how to integrate with with CMake's model. See: #25328 --- Help/manual/cmake-cxxmodules.7.rst | 1 + Source/cmVisualStudio10TargetGenerator.cxx | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Help/manual/cmake-cxxmodules.7.rst b/Help/manual/cmake-cxxmodules.7.rst index 5776421..99915e3 100644 --- a/Help/manual/cmake-cxxmodules.7.rst +++ b/Help/manual/cmake-cxxmodules.7.rst @@ -68,5 +68,6 @@ For the :ref:`Visual Studio Generators`: - Only Visual Studio 2022 and MSVC toolsets 14.34 (Visual Studio 17.4) and newer. - No support for exporting or installing BMI or module information. +- No support for compiling BMIs from ``IMPORTED`` targets with C++ modules. - No diagnosis of using modules provided by ``PRIVATE`` sources from ``PUBLIC`` module sources. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ce94fe1..4860d9a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -358,6 +358,15 @@ std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString( void cmVisualStudio10TargetGenerator::Generate() { + if (this->GeneratorTarget->IsSynthetic()) { + this->GeneratorTarget->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Target \"", this->GeneratorTarget->GetName(), + "\" contains C++ modules intended for BMI-only compilation. " + "This is not yet supported by the Visual Studio generator.")); + return; + } + for (std::string const& config : this->Configurations) { this->GeneratorTarget->CheckCxxModuleStatus(config); } -- cgit v0.12