summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-02-14 14:48:10 (GMT)
committerBrad King <brad.king@kitware.com>2022-02-14 14:48:10 (GMT)
commite6e9c8e484e7e0307f948d035c0d87bdee985743 (patch)
treeffb796f5821a3bf57201ea23ff9f75542f1445fa
parent21d8a8680448eba758125d28deb4d44f9919e21d (diff)
parent83d79636bff4963f16215b219c5941618a58c7bd (diff)
downloadCMake-e6e9c8e484e7e0307f948d035c0d87bdee985743.zip
CMake-e6e9c8e484e7e0307f948d035c0d87bdee985743.tar.gz
CMake-e6e9c8e484e7e0307f948d035c0d87bdee985743.tar.bz2
Merge branch 'restore-target-export-includes' into release-3.22
Merge-request: !6969
-rw-r--r--Source/cmExportFileGenerator.cxx5
-rw-r--r--Source/cmExportFileGenerator.h4
-rw-r--r--Source/cmExportInstallFileGenerator.cxx3
-rw-r--r--Source/cmInstallCommand.cxx2
-rw-r--r--Source/cmTarget.cxx16
-rw-r--r--Source/cmTarget.h7
-rw-r--r--Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake19
-rw-r--r--Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt5
-rw-r--r--Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt5
-rw-r--r--Tests/RunCMake/install/EXPORT-TargetTwice.cmake17
-rw-r--r--Tests/RunCMake/install/RunCMakeTest.cmake1
11 files changed, 71 insertions, 13 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 8ca9a66..8b0f64e 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -367,7 +367,8 @@ void cmExportFileGenerator::PopulateSourcesInterface(
void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
cmGeneratorTarget const* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets,
+ cmTargetExport const& te)
{
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
@@ -377,7 +378,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
cmGeneratorExpression ge;
std::string dirs = cmGeneratorExpression::Preprocess(
- cmJoin(target->Target->GetInstallIncludeDirectoriesEntries(), ";"),
+ cmJoin(target->Target->GetInstallIncludeDirectoriesEntries(te), ";"),
preprocessRule, true);
this->ReplaceInstallPrefix(dirs);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 24e048b..29a6a98 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -16,6 +16,7 @@
#include "cmVersionConfig.h"
class cmGeneratorTarget;
+class cmTargetExport;
#define STRINGIFY_HELPER(X) #X
#define STRINGIFY(X) STRINGIFY_HELPER(X)
@@ -146,7 +147,8 @@ protected:
void PopulateIncludeDirectoriesInterface(
cmGeneratorTarget const* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets,
+ cmTargetExport const& te);
void PopulateSourcesInterface(
cmGeneratorTarget const* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index e9ac875..4a3c565 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -86,7 +86,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
ImportPropertyMap properties;
this->PopulateIncludeDirectoriesInterface(
- gt, cmGeneratorExpression::InstallInterface, properties, missingTargets);
+ gt, cmGeneratorExpression::InstallInterface, properties, missingTargets,
+ *te);
this->PopulateSourcesInterface(gt, cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", gt,
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index eaf88f6..92e3bb5 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -683,7 +683,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
te->RuntimeGenerator = runtimeGenerator.get();
te->ObjectsGenerator = objectGenerator.get();
target.AddInstallIncludeDirectories(
- cmMakeRange(includesArgs.GetIncludeDirs()));
+ *te, cmMakeRange(includesArgs.GetIncludeDirs()));
te->NamelinkOnly = namelinkOnly;
helper.Makefile->GetGlobalGenerator()
->GetExportSets()[exports]
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 97d60cf..45e23d3 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -191,7 +191,8 @@ public:
cmTarget::LinkLibraryVectorType OriginalLinkLibraries;
std::map<std::string, BTs<std::string>> LanguageStandardProperties;
std::vector<BT<std::string>> IncludeDirectoriesEntries;
- std::vector<std::string> InstallIncludeDirectoriesEntries;
+ std::map<cmTargetExport const*, std::vector<std::string>>
+ InstallIncludeDirectoriesEntries;
std::vector<BT<std::string>> CompileOptionsEntries;
std::vector<BT<std::string>> CompileFeaturesEntries;
std::vector<BT<std::string>> CompileDefinitionsEntries;
@@ -1054,15 +1055,18 @@ std::set<std::string> const& cmTarget::GetSystemIncludeDirectories() const
return this->impl->SystemIncludeDirectories;
}
-void cmTarget::AddInstallIncludeDirectories(cmStringRange const& incs)
+void cmTarget::AddInstallIncludeDirectories(cmTargetExport const& te,
+ cmStringRange const& incs)
{
- std::copy(incs.begin(), incs.end(),
- std::back_inserter(this->impl->InstallIncludeDirectoriesEntries));
+ std::copy(
+ incs.begin(), incs.end(),
+ std::back_inserter(this->impl->InstallIncludeDirectoriesEntries[&te]));
}
-cmStringRange cmTarget::GetInstallIncludeDirectoriesEntries() const
+cmStringRange cmTarget::GetInstallIncludeDirectoriesEntries(
+ cmTargetExport const& te) const
{
- return cmMakeRange(this->impl->InstallIncludeDirectoriesEntries);
+ return cmMakeRange(this->impl->InstallIncludeDirectoriesEntries[&te]);
}
cmBTStringRange cmTarget::GetIncludeDirectoriesEntries() const
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 3cf6942..95aa4d3 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -26,6 +26,7 @@ class cmMakefile;
class cmMessenger;
class cmPropertyMap;
class cmSourceFile;
+class cmTargetExport;
class cmTargetInternals;
/** \class cmTarget
@@ -232,8 +233,10 @@ public:
void AddSystemIncludeDirectories(std::set<std::string> const& incs);
std::set<std::string> const& GetSystemIncludeDirectories() const;
- void AddInstallIncludeDirectories(cmStringRange const& incs);
- cmStringRange GetInstallIncludeDirectoriesEntries() const;
+ void AddInstallIncludeDirectories(cmTargetExport const& te,
+ cmStringRange const& incs);
+ cmStringRange GetInstallIncludeDirectoriesEntries(
+ cmTargetExport const& te) const;
BTs<std::string> const* GetLanguageStandardProperty(
const std::string& propertyName) const;
diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake b/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake
new file mode 100644
index 0000000..97677ca
--- /dev/null
+++ b/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake
@@ -0,0 +1,19 @@
+set(pkg1_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/pkg1/pkg1.cmake")
+file(STRINGS "${pkg1_cmake}" pkg1_includes REGEX INTERFACE_INCLUDE_DIRECTORIES)
+set(pkg1_expect [[INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg1/inc"]])
+if(NOT pkg1_includes MATCHES "${pkg1_expect}")
+ set(RunCMake_TEST_FAILED "pkg1 has unexpected INTERFACE_INCLUDE_DIRECTORIES line:
+ ${pkg1_includes}
+It does not match:
+ ${pkg1_expect}")
+endif()
+
+set(pkg2_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/pkg2/pkg2.cmake")
+file(STRINGS "${pkg2_cmake}" pkg2_includes REGEX INTERFACE_INCLUDE_DIRECTORIES)
+set(pkg2_expect [[INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg2/inc"]])
+if(NOT pkg2_includes MATCHES "${pkg2_expect}")
+ set(RunCMake_TEST_FAILED "pkg2 has unexpected INTERFACE_INCLUDE_DIRECTORIES line:
+ ${pkg2_includes}
+It does not match:
+ ${pkg2_expect}")
+endif()
diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt
new file mode 100644
index 0000000..592f79c
--- /dev/null
+++ b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt
@@ -0,0 +1,5 @@
+.+
+set_target_properties\(pkg1::foo PROPERTIES
+.+INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg1/inc"
+\)
+.+
diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt
new file mode 100644
index 0000000..ebfc43e
--- /dev/null
+++ b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt
@@ -0,0 +1,5 @@
+.+
+set_target_properties\(pkg2::foo PROPERTIES
+.+INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg2/inc"
+\)
+.+
diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice.cmake b/Tests/RunCMake/install/EXPORT-TargetTwice.cmake
new file mode 100644
index 0000000..cac4ff2
--- /dev/null
+++ b/Tests/RunCMake/install/EXPORT-TargetTwice.cmake
@@ -0,0 +1,17 @@
+enable_language(C)
+
+add_library(foo STATIC empty.c)
+
+install(TARGETS foo
+ EXPORT pkg1
+ ARCHIVE DESTINATION pkg1/lib
+ INCLUDES DESTINATION pkg1/inc
+ )
+install(EXPORT pkg1 DESTINATION pkg1)
+
+install(TARGETS foo
+ EXPORT pkg2
+ ARCHIVE DESTINATION pkg2/lib
+ INCLUDES DESTINATION pkg2/inc
+ )
+install(EXPORT pkg2 DESTINATION pkg2)
diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake
index f79a3ea..7c12d4a 100644
--- a/Tests/RunCMake/install/RunCMakeTest.cmake
+++ b/Tests/RunCMake/install/RunCMakeTest.cmake
@@ -82,6 +82,7 @@ run_cmake(EXPORT-OldIFace)
run_cmake(EXPORT-UnknownExport)
run_cmake(EXPORT-NamelinkOnly)
run_cmake(EXPORT-SeparateNamelink)
+run_cmake(EXPORT-TargetTwice)
run_cmake(CMP0062-OLD)
run_cmake(CMP0062-NEW)
run_cmake(CMP0062-WARN)