summaryrefslogtreecommitdiffstats
path: root/Source/cmExportFileGenerator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-01-15 04:58:28 (GMT)
committerRobert Maynard <rmaynard@nvidia.com>2023-04-12 14:43:48 (GMT)
commit0fb923c46041d67110c8e0907afdf66b3b25f25a (patch)
tree471126bf0dcb9ef4481716d38524b57a01ca2973 /Source/cmExportFileGenerator.cxx
parent6c11f7e4a8805189835c04a398864f96081b3183 (diff)
downloadCMake-0fb923c46041d67110c8e0907afdf66b3b25f25a.zip
CMake-0fb923c46041d67110c8e0907afdf66b3b25f25a.tar.gz
CMake-0fb923c46041d67110c8e0907afdf66b3b25f25a.tar.bz2
cmGeneratorExpressionNode: implement `COMPILE_ONLY` genex
This generator expression is the inverse of `LINK_ONLY` and only coveys usage requirements for the purposes of compilation. Its intended use is to avoid needing to export targets that do not have link usage requirements (e.g., header-only libraries) when used by another target. It will also be used to represent private usage requirements on exported C++ module-containing targets in the future. Eventually there should be logic to collapse nesting of `$<COMPILE_ONLY>` and `$<LINK_ONLY>` when generating instances of either. A TODO is left in the code for this case. See: #15415
Diffstat (limited to 'Source/cmExportFileGenerator.cxx')
-rw-r--r--Source/cmExportFileGenerator.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 6e7ef4e..e997158 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -734,6 +734,22 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
lastPos = nameStartPos + libName.size() + 1;
}
+ while (errorString.empty() &&
+ (pos = input.find("$<COMPILE_ONLY:", lastPos)) != std::string::npos) {
+ std::string::size_type nameStartPos = pos + cmStrLen("$<COMPILE_ONLY:");
+ std::string::size_type endPos = input.find('>', nameStartPos);
+ if (endPos == std::string::npos) {
+ errorString = "$<COMPILE_ONLY:...> expression incomplete";
+ break;
+ }
+ std::string libName = input.substr(nameStartPos, endPos - nameStartPos);
+ if (cmGeneratorExpression::IsValidTargetName(libName) &&
+ this->AddTargetNamespace(libName, target, lg)) {
+ input.replace(nameStartPos, endPos - nameStartPos, libName);
+ }
+ lastPos = nameStartPos + libName.size() + 1;
+ }
+
this->ReplaceInstallPrefix(input);
if (!errorString.empty()) {