diff options
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmExportFileGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmExportInstallFileGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmInstallCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 16 | ||||
-rw-r--r-- | Source/cmTarget.h | 7 | ||||
-rw-r--r-- | Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake | 19 | ||||
-rw-r--r-- | Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/install/EXPORT-TargetTwice.cmake | 17 | ||||
-rw-r--r-- | Tests/RunCMake/install/RunCMakeTest.cmake | 1 |
11 files changed, 70 insertions, 13 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 2d80f0e..b46b933 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -375,7 +375,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); @@ -385,7 +386,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 5875247..d50f7e8 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -148,7 +148,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 2dd8b8f..f232440 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -90,7 +90,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 52a411b..a77b26b 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -760,7 +760,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, te->FileSetGenerators[gen->GetFileSet()] = gen.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 87fce92..6059055 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -192,7 +192,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; @@ -1079,15 +1080,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 18e39c7..0cdd2fc 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -27,6 +27,7 @@ class cmListFileContext; class cmMakefile; class cmPropertyMap; class cmSourceFile; +class cmTargetExport; class cmTargetInternals; template <typename T> @@ -237,8 +238,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) |