Commit 23d21b78 authored by Brad King's avatar Brad King
Browse files

Do not export INTERFACE_LINK_LIBRARIES from non-linkable targets

When cmExportFileGenerator::SetImportLinkInterface exports the old
LINK_INTERFACE_LIBRARIES property values it skips doing so for
non-linkable targets because target->GetLinkInterface returns NULL for
such targets.

Since cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty
looks at the INTERFACE_LINK_LIBRARIES property directly instead of using
the computed link interface, teach it to skip exporting the property if
target->IsLinkable returns false.

Extend the RunCMake.CMP0022 test with a case covering this.  Simply
export an executable target that links to a library that is not
exported.
parent ef10b87c
...@@ -185,6 +185,10 @@ bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( ...@@ -185,6 +185,10 @@ bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
ImportPropertyMap &properties, ImportPropertyMap &properties,
std::vector<std::string> &missingTargets) std::vector<std::string> &missingTargets)
{ {
if(!target->IsLinkable())
{
return false;
}
const char *input = target->GetProperty("INTERFACE_LINK_LIBRARIES"); const char *input = target->GetProperty("INTERFACE_LINK_LIBRARIES");
if (input) if (input)
{ {
......
enable_language(CXX)
cmake_policy(SET CMP0022 NEW)
add_library(testLib empty_vs6_1.cpp)
add_executable(testExe empty_vs6_2.cpp)
target_link_libraries(testExe testLib)
export(TARGETS testExe FILE "${CMAKE_CURRENT_BINARY_DIR}/cmp0022NEW-exe.cmake")
...@@ -8,4 +8,5 @@ run_cmake(CMP0022-NOWARN-shared) ...@@ -8,4 +8,5 @@ run_cmake(CMP0022-NOWARN-shared)
run_cmake(CMP0022-NOWARN-static) run_cmake(CMP0022-NOWARN-static)
run_cmake(CMP0022-NOWARN-static-link_libraries) run_cmake(CMP0022-NOWARN-static-link_libraries)
run_cmake(CMP0022-export) run_cmake(CMP0022-export)
run_cmake(CMP0022-export-exe)
run_cmake(CMP0022-install-export) run_cmake(CMP0022-install-export)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment