summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-10-16 16:03:41 (GMT)
committerBrad King <brad.king@kitware.com>2019-10-16 16:48:20 (GMT)
commit0e436c573c52add744f0ff7c8845be9c7ff381a0 (patch)
tree1182550d8325eb9d822dd54763673e2d26e5737b
parent9150c818b7d2afb868575fcb2e0c9ba62b9d7f85 (diff)
downloadCMake-0e436c573c52add744f0ff7c8845be9c7ff381a0.zip
CMake-0e436c573c52add744f0ff7c8845be9c7ff381a0.tar.gz
CMake-0e436c573c52add744f0ff7c8845be9c7ff381a0.tar.bz2
install,export: Do not treat language names as target names
When generating `IMPORTED_LINK_INTERFACE_LANGUAGES`, do not treat the entries as target names. Fixes: #19846
-rw-r--r--Source/cmExportFileGenerator.cxx31
-rw-r--r--Source/cmExportFileGenerator.h8
-rw-r--r--Tests/ExportImport/Export/CMakeLists.txt5
3 files changed, 30 insertions, 14 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 3d7eccc..aeef602 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -752,9 +752,9 @@ void cmExportFileGenerator::SetImportLinkInterface(
if (iface->ImplementationIsInterface) {
// Policy CMP0022 must not be NEW.
- this->SetImportLinkProperty(suffix, target,
- "IMPORTED_LINK_INTERFACE_LIBRARIES",
- iface->Libraries, properties, missingTargets);
+ this->SetImportLinkProperty(
+ suffix, target, "IMPORTED_LINK_INTERFACE_LIBRARIES", iface->Libraries,
+ properties, missingTargets, ImportLinkPropertyTargetNames::Yes);
return;
}
@@ -832,14 +832,14 @@ void cmExportFileGenerator::SetImportDetailProperties(
// Add the transitive link dependencies for this configuration.
if (cmLinkInterface const* iface =
target->GetLinkInterface(config, target)) {
- this->SetImportLinkProperty(suffix, target,
- "IMPORTED_LINK_INTERFACE_LANGUAGES",
- iface->Languages, properties, missingTargets);
+ this->SetImportLinkProperty(
+ suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", iface->Languages,
+ properties, missingTargets, ImportLinkPropertyTargetNames::No);
std::vector<std::string> dummy;
- this->SetImportLinkProperty(suffix, target,
- "IMPORTED_LINK_DEPENDENT_LIBRARIES",
- iface->SharedDeps, properties, dummy);
+ this->SetImportLinkProperty(
+ suffix, target, "IMPORTED_LINK_DEPENDENT_LIBRARIES", iface->SharedDeps,
+ properties, dummy, ImportLinkPropertyTargetNames::Yes);
if (iface->Multiplicity > 0) {
std::string prop =
cmStrCat("IMPORTED_LINK_INTERFACE_MULTIPLICITY", suffix);
@@ -880,7 +880,8 @@ template <typename T>
void cmExportFileGenerator::SetImportLinkProperty(
std::string const& suffix, cmGeneratorTarget* target,
const std::string& propName, std::vector<T> const& entries,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets,
+ ImportLinkPropertyTargetNames targetNames)
{
// Skip the property if there are no entries.
if (entries.empty()) {
@@ -895,9 +896,13 @@ void cmExportFileGenerator::SetImportLinkProperty(
link_entries += sep;
sep = ";";
- std::string temp = asString(l);
- this->AddTargetNamespace(temp, target, missingTargets);
- link_entries += temp;
+ if (targetNames == ImportLinkPropertyTargetNames::Yes) {
+ std::string temp = asString(l);
+ this->AddTargetNamespace(temp, target, missingTargets);
+ link_entries += temp;
+ } else {
+ link_entries += asString(l);
+ }
}
// Store the property.
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index b04a31e..0d69779 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -102,13 +102,19 @@ protected:
ImportPropertyMap& properties,
std::vector<std::string>& missingTargets);
+ enum class ImportLinkPropertyTargetNames
+ {
+ Yes,
+ No,
+ };
template <typename T>
void SetImportLinkProperty(std::string const& suffix,
cmGeneratorTarget* target,
const std::string& propName,
std::vector<T> const& entries,
ImportPropertyMap& properties,
- std::vector<std::string>& missingTargets);
+ std::vector<std::string>& missingTargets,
+ ImportLinkPropertyTargetNames targetNames);
/** Each subclass knows how to generate its kind of export file. */
virtual bool GenerateMainFile(std::ostream& os) = 0;
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index 5cf04e8..9d8a248 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -645,3 +645,8 @@ if(CMAKE_GENERATOR MATCHES "Make|Ninja")
EXPORT RequiredExp DESTINATION lib)
export(TARGETS testLinkDepends NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake)
endif()
+
+# Test the presence of targets named the same as languages.
+# IMPORTED_LINK_INTERFACE_LANGUAGES entries should not be targets.
+add_library(C INTERFACE)
+add_library(CXX INTERFACE)