diff options
author | Brad King <brad.king@kitware.com> | 2023-10-17 13:49:57 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-10-17 13:50:06 (GMT) |
commit | 84ac583bc6307eb73042762f40e381126199d972 (patch) | |
tree | 17a800f5a83af232bcfd4667ea63168952fd2153 /Source | |
parent | ec916350db5e45dbd423b7ab93f17004d06b1e7c (diff) | |
parent | 0f36156740aaea82795444c8468fbfd5dc1e3810 (diff) | |
download | CMake-84ac583bc6307eb73042762f40e381126199d972.zip CMake-84ac583bc6307eb73042762f40e381126199d972.tar.gz CMake-84ac583bc6307eb73042762f40e381126199d972.tar.bz2 |
Merge topic 'cxxmodules-export-fileset-info' into release-3.28
0f36156740 cxxmodules: include `INCLUDES DESTINATION` directories
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8886
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExportBuildFileGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 35 | ||||
-rw-r--r-- | Source/cmExportFileGenerator.h | 6 | ||||
-rw-r--r-- | Source/cmExportInstallFileGenerator.cxx | 6 |
4 files changed, 40 insertions, 9 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 69572f4..bf3bb8b 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -127,7 +127,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) std::string errorMessage; if (!this->PopulateCxxModuleExportProperties( - gte, properties, cmGeneratorExpression::BuildInterface, + gte, properties, cmGeneratorExpression::BuildInterface, {}, errorMessage)) { this->LG->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage( MessageType::FATAL_ERROR, errorMessage, 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; + } } } } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 6fa19ee..f396e0e 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -143,7 +143,8 @@ protected: void PopulateIncludeDirectoriesInterface( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, cmTargetExport const& te); + ImportPropertyMap& properties, cmTargetExport const& te, + std::string& includesDestinationDirs); void PopulateSourcesInterface( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, @@ -177,7 +178,8 @@ protected: bool PopulateCxxModuleExportProperties( cmGeneratorTarget const* gte, ImportPropertyMap& properties, - cmGeneratorExpression::PreprocessContext ctx, std::string& errorMessage); + cmGeneratorExpression::PreprocessContext ctx, + std::string const& includesDestinationDirs, std::string& errorMessage); bool PopulateExportProperties(cmGeneratorTarget const* gte, ImportPropertyMap& properties, std::string& errorMessage); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 908bb31..a264f5e 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -92,8 +92,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) ImportPropertyMap properties; + std::string includesDestinationDirs; this->PopulateIncludeDirectoriesInterface( - gt, cmGeneratorExpression::InstallInterface, properties, *te); + gt, cmGeneratorExpression::InstallInterface, properties, *te, + includesDestinationDirs); this->PopulateSourcesInterface(gt, cmGeneratorExpression::InstallInterface, properties); this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", gt, @@ -128,7 +130,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) std::string errorMessage; if (!this->PopulateCxxModuleExportProperties( gt, properties, cmGeneratorExpression::InstallInterface, - errorMessage)) { + includesDestinationDirs, errorMessage)) { cmSystemTools::Error(errorMessage); return false; } |