summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-12-11 16:53:26 (GMT)
committerBrad King <brad.king@kitware.com>2024-12-11 17:34:29 (GMT)
commit854eba0c53505190adb8fdd32cbdaed318d8dfda (patch)
tree7ccb5e38573b93dee2be4cad4bf8f05b7fb95b83 /Source
parentcd179e75606c6dc821b10574927e449b397b931c (diff)
downloadCMake-854eba0c53505190adb8fdd32cbdaed318d8dfda.zip
CMake-854eba0c53505190adb8fdd32cbdaed318d8dfda.tar.gz
CMake-854eba0c53505190adb8fdd32cbdaed318d8dfda.tar.bz2
target_sources: Improve error message for CXX_MODULES on INTERFACE libraries
We support non-compiled `SOURCES` on `INTERFACE` libraries, and also support `CXX_MODULES` on *imported* `INTERFACE` libraries (via synthetic targets that compile module interface units). However, we do not support `CXX_MODULES` on non-imported `INTERFACE` libraries because there is no place to hold module interface unit's object files for their module initializers. Previously this was not explicitly rejected, and so was diagnosed only by "CMake Internal Error" messages due to assumption violations in the implementation. Fixes: #26524 Co-authored-by: Ben Boeckel <ben.boeckel@kitware.com>
Diffstat (limited to 'Source')
-rw-r--r--Source/cmTargetSourcesCommand.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
index babbaa5..cdb9836 100644
--- a/Source/cmTargetSourcesCommand.cxx
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -265,6 +265,18 @@ bool TargetSourcesImpl::HandleOneFileSet(
return false;
}
+ if (cmFileSetVisibilityIsForSelf(visibility) &&
+ this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY &&
+ !this->Target->IsImported()) {
+ if (type == "CXX_MODULES"_s) {
+ this->SetError(R"(File set TYPE "CXX_MODULES" may not have "PUBLIC" )"
+ R"(or "PRIVATE" visibility on INTERFACE libraries.)");
+ return false;
+ }
+ }
+
+ // FIXME(https://wg21.link/P3470): This condition can go
+ // away when interface-only module units are a thing.
if (cmFileSetVisibilityIsForInterface(visibility) &&
!cmFileSetVisibilityIsForSelf(visibility) &&
!this->Target->IsImported()) {