cmTarget: Fix iface libraries and languages for static libraries.
This commit is contained in:
parent
f94bdb3deb
commit
c8a10ba9ad
|
@ -6467,6 +6467,15 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
|
|||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iface.Libraries = impl->Libraries;
|
||||
if(this->GetType() == cmTarget::STATIC_LIBRARY)
|
||||
{
|
||||
// Targets using this archive need its language runtime libraries.
|
||||
iface.Languages = impl->Languages;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6495,7 +6504,8 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
|
|||
headTarget,
|
||||
this, &dagChecker), iface.Libraries);
|
||||
|
||||
if(this->GetType() == cmTarget::SHARED_LIBRARY)
|
||||
if(this->GetType() == cmTarget::SHARED_LIBRARY
|
||||
|| this->GetType() == cmTarget::STATIC_LIBRARY)
|
||||
{
|
||||
// Shared libraries may have runtime implementation dependencies
|
||||
// on other shared libraries that are not in the interface.
|
||||
|
@ -6529,6 +6539,11 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
|
|||
}
|
||||
}
|
||||
}
|
||||
if(this->GetType() == cmTarget::STATIC_LIBRARY)
|
||||
{
|
||||
// Targets using this archive need its language runtime libraries.
|
||||
iface.Languages = impl->Languages;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN
|
||||
|
|
|
@ -16,3 +16,12 @@ assert_property(cmp0022ifacelib INTERFACE_LINK_LIBRARIES "")
|
|||
|
||||
add_executable(cmp0022exe cmp0022exe.cpp)
|
||||
target_link_libraries(cmp0022exe cmp0022lib)
|
||||
|
||||
add_library(staticlib1 STATIC staticlib1.cpp)
|
||||
generate_export_header(staticlib1)
|
||||
add_library(staticlib2 STATIC staticlib2.cpp)
|
||||
generate_export_header(staticlib2)
|
||||
target_link_libraries(staticlib1 LINK_PUBLIC staticlib2)
|
||||
|
||||
add_executable(staticlib_exe staticlib_exe.cpp)
|
||||
target_link_libraries(staticlib_exe staticlib1)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
int staticlib1() { return 0; }
|
|
@ -0,0 +1,4 @@
|
|||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
int staticlib1();
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
int staticlib2() { return 0; }
|
|
@ -0,0 +1,4 @@
|
|||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
int staticlib2();
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
#include "staticlib1.h"
|
||||
#include "staticlib2.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
return staticlib1() + staticlib2();
|
||||
}
|
Loading…
Reference in New Issue