From 70c6557285793d9944f4177d3bee3f1570ace308 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 18 May 2017 10:15:11 -0400 Subject: Tests: Fix RunCMake.CMP0022 tll case for Debug configuration The `CMP0022-WARN-tll` case overrides legacy properties set by `target_link_libraries` so that we can verify that the policy warning is emitted. When building in the Debug configuration, the `_DEBUG` variant of the legacy property is set/checked too. Fix the test case to override both variants. Previously it only passed because `cmComputeTargetDepends::AddInterfaceDepends` always evaluated dependencies with the "" configuration. --- Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt | 4 ++-- Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt index f672285..5d39214 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt @@ -4,13 +4,13 @@ CMake Warning \(dev\) in CMakeLists.txt: cmake_policy command to set the policy and suppress this warning. Target "bar" has an INTERFACE_LINK_LIBRARIES property which differs from - its LINK_INTERFACE_LIBRARIES properties. + its LINK_INTERFACE_LIBRARIES(_DEBUG)? properties. INTERFACE_LINK_LIBRARIES: foo - LINK_INTERFACE_LIBRARIES: + LINK_INTERFACE_LIBRARIES(_DEBUG)?: bat diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake index 11b4e22..03223e8 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake @@ -5,7 +5,9 @@ add_library(foo SHARED empty_vs6_1.cpp) add_library(bar SHARED empty_vs6_2.cpp) add_library(bat SHARED empty_vs6_3.cpp) target_link_libraries(bar LINK_PUBLIC foo) +# Replace the compatibility values set by target_link_libraries set_property(TARGET bar PROPERTY LINK_INTERFACE_LIBRARIES bat) +set_property(TARGET bar PROPERTY LINK_INTERFACE_LIBRARIES_DEBUG bat) add_library(user SHARED empty.cpp) target_link_libraries(user bar) -- cgit v0.12 From 5a913794d2931c3de00464cf261215a173f5ab8b Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 17 May 2017 13:19:15 -0400 Subject: cmComputeTargetDepends: Avoid computing with empty configuration Fix `AddInterfaceDepends` to combine all configurations using the same approach that `CollectTargetDepends` does. Fixes: #16896 --- Source/cmComputeTargetDepends.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index cfebda2..8ca8763 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -294,9 +294,11 @@ void cmComputeTargetDepends::AddInterfaceDepends( } if (dependee) { - this->AddInterfaceDepends(depender_index, dependee, "", emitted); std::vector configs; depender->Makefile->GetConfigurations(configs); + if (configs.empty()) { + configs.push_back(""); + } for (std::vector::const_iterator it = configs.begin(); it != configs.end(); ++it) { // A target should not depend on itself. -- cgit v0.12 From 87a37e647587d4891b36db92bd33950ccc864c6b Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 17 May 2017 13:29:37 -0400 Subject: cmComputeTargetDepends: Avoid nested loops over configurations `AddInterfaceDepends` is only called from `CollectTargetDepends` inside our loop over all configurations so it doesn't need its own such loop. --- Source/cmComputeTargetDepends.cxx | 20 ++++++-------------- Source/cmComputeTargetDepends.h | 1 + 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 8ca8763..ff19eac 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -238,7 +238,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Don't emit the same library twice for this target. if (emitted.insert(*lib).second) { this->AddTargetDepend(depender_index, *lib, true); - this->AddInterfaceDepends(depender_index, *lib, emitted); + this->AddInterfaceDepends(depender_index, *lib, *it, emitted); } } } @@ -273,7 +273,7 @@ void cmComputeTargetDepends::AddInterfaceDepends( // Don't emit the same library twice for this target. if (emitted.insert(*lib).second) { this->AddTargetDepend(depender_index, *lib, true); - this->AddInterfaceDepends(depender_index, *lib, emitted); + this->AddInterfaceDepends(depender_index, *lib, config, emitted); } } } @@ -281,7 +281,7 @@ void cmComputeTargetDepends::AddInterfaceDepends( void cmComputeTargetDepends::AddInterfaceDepends( int depender_index, cmLinkItem const& dependee_name, - std::set& emitted) + const std::string& config, std::set& emitted) { cmGeneratorTarget const* depender = this->Targets[depender_index]; cmGeneratorTarget const* dependee = dependee_name.Target; @@ -294,17 +294,9 @@ void cmComputeTargetDepends::AddInterfaceDepends( } if (dependee) { - std::vector configs; - depender->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.push_back(""); - } - for (std::vector::const_iterator it = configs.begin(); - it != configs.end(); ++it) { - // A target should not depend on itself. - emitted.insert(depender->GetName()); - this->AddInterfaceDepends(depender_index, dependee, *it, emitted); - } + // A target should not depend on itself. + emitted.insert(depender->GetName()); + this->AddInterfaceDepends(depender_index, dependee, config, emitted); } } diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index ccf99de..e93e376 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -50,6 +50,7 @@ private: bool linking); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); void AddInterfaceDepends(int depender_index, cmLinkItem const& dependee_name, + const std::string& config, std::set& emitted); void AddInterfaceDepends(int depender_index, cmGeneratorTarget const* dependee, -- cgit v0.12