summaryrefslogtreecommitdiffstats
path: root/Source/cmExportFileGenerator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-10-16 17:57:54 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2023-10-16 17:57:54 (GMT)
commit0f36156740aaea82795444c8468fbfd5dc1e3810 (patch)
tree793efb3ddb7553621e59915ddecc76cc839c5a90 /Source/cmExportFileGenerator.cxx
parent7080b4ae8354b9e8deada0f35ff02a1bc1cc13a7 (diff)
downloadCMake-0f36156740aaea82795444c8468fbfd5dc1e3810.zip
CMake-0f36156740aaea82795444c8468fbfd5dc1e3810.tar.gz
CMake-0f36156740aaea82795444c8468fbfd5dc1e3810.tar.bz2
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
Diffstat (limited to 'Source/cmExportFileGenerator.cxx')
-rw-r--r--Source/cmExportFileGenerator.cxx35
1 files changed, 31 insertions, 4 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index dae061b..d0e69fb 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -374,10 +374,13 @@ void cmExportFileGenerator::PopulateSourcesInterface(
void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
cmGeneratorTarget const* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, cmTargetExport const& te)
+ ImportPropertyMap& properties, cmTargetExport const& te,
+ std::string& includesDestinationDirs)
{
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
+ includesDestinationDirs.clear();
+
const char* propName = "INTERFACE_INCLUDE_DIRECTORIES";
cmValue input = target->GetProperty(propName);
@@ -414,6 +417,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
}
prefixItems(exportDirs);
+ includesDestinationDirs = exportDirs;
std::string includes = (input ? *input : "");
const char* sep = input ? ";" : "";
@@ -1260,8 +1264,23 @@ enum class PropertyType
{
Strings,
Paths,
+ IncludePaths,
};
+namespace {
+bool PropertyTypeIsForPaths(PropertyType pt)
+{
+ switch (pt) {
+ case PropertyType::Strings:
+ return false;
+ case PropertyType::Paths:
+ case PropertyType::IncludePaths:
+ return true;
+ }
+ return false;
+}
+}
+
struct ModulePropertyTable
{
cm::static_string_view Name;
@@ -1270,7 +1289,8 @@ struct ModulePropertyTable
bool cmExportFileGenerator::PopulateCxxModuleExportProperties(
cmGeneratorTarget const* gte, ImportPropertyMap& properties,
- cmGeneratorExpression::PreprocessContext ctx, std::string& errorMessage)
+ cmGeneratorExpression::PreprocessContext ctx,
+ std::string const& includesDestinationDirs, std::string& errorMessage)
{
if (!gte->HaveCxx20ModuleSources(&errorMessage)) {
return true;
@@ -1292,7 +1312,7 @@ bool cmExportFileGenerator::PopulateCxxModuleExportProperties(
}
const ModulePropertyTable exportedModuleProperties[] = {
- { "INCLUDE_DIRECTORIES"_s, PropertyType::Paths },
+ { "INCLUDE_DIRECTORIES"_s, PropertyType::IncludePaths },
{ "COMPILE_DEFINITIONS"_s, PropertyType::Strings },
{ "COMPILE_OPTIONS"_s, PropertyType::Strings },
{ "COMPILE_FEATURES"_s, PropertyType::Strings },
@@ -1310,9 +1330,16 @@ bool cmExportFileGenerator::PopulateCxxModuleExportProperties(
properties[exportedPropName] =
cmGeneratorExpression::Preprocess(*prop, ctx);
if (ctx == cmGeneratorExpression::InstallInterface &&
- propEntry.Type == PropertyType::Paths) {
+ PropertyTypeIsForPaths(propEntry.Type)) {
this->ReplaceInstallPrefix(properties[exportedPropName]);
prefixItems(properties[exportedPropName]);
+ if (propEntry.Type == PropertyType::IncludePaths &&
+ !includesDestinationDirs.empty()) {
+ if (!properties[exportedPropName].empty()) {
+ properties[exportedPropName] += ';';
+ }
+ properties[exportedPropName] += includesDestinationDirs;
+ }
}
}
}