Genex: Disallow LINKER_LANGUAGE only when used on a static library.
For shared libraries and executables, the linker_language is indepenedent of the linked libraries.
This commit is contained in:
parent
c8a10ba9ad
commit
b8dc7fad23
|
@ -790,11 +790,12 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
||||||
|
|
||||||
if (propertyName == "LINKER_LANGUAGE")
|
if (propertyName == "LINKER_LANGUAGE")
|
||||||
{
|
{
|
||||||
if (dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries())
|
if (target->LinkLanguagePropagatesToDependents() &&
|
||||||
|
dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries())
|
||||||
{
|
{
|
||||||
reportError(context, content->GetOriginalExpression(),
|
reportError(context, content->GetOriginalExpression(),
|
||||||
"LINKER_LANGUAGE target property can not be used while evaluating "
|
"LINKER_LANGUAGE target property can not be used while evaluating "
|
||||||
"link libraries");
|
"link libraries for a static library");
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
const char *lang = target->GetLinkerLanguage(context->Config);
|
const char *lang = target->GetLinkerLanguage(context->Config);
|
||||||
|
|
|
@ -6241,7 +6241,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the link languages.
|
// Get the link languages.
|
||||||
if(this->GetType() == cmTarget::STATIC_LIBRARY)
|
if(this->LinkLanguagePropagatesToDependents())
|
||||||
{
|
{
|
||||||
std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES";
|
std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES";
|
||||||
linkProp += suffix;
|
linkProp += suffix;
|
||||||
|
@ -6470,7 +6470,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iface.Libraries = impl->Libraries;
|
iface.Libraries = impl->Libraries;
|
||||||
if(this->GetType() == cmTarget::STATIC_LIBRARY)
|
if(this->LinkLanguagePropagatesToDependents())
|
||||||
{
|
{
|
||||||
// Targets using this archive need its language runtime libraries.
|
// Targets using this archive need its language runtime libraries.
|
||||||
iface.Languages = impl->Languages;
|
iface.Languages = impl->Languages;
|
||||||
|
@ -6539,7 +6539,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this->GetType() == cmTarget::STATIC_LIBRARY)
|
if(this->LinkLanguagePropagatesToDependents())
|
||||||
{
|
{
|
||||||
// Targets using this archive need its language runtime libraries.
|
// Targets using this archive need its language runtime libraries.
|
||||||
iface.Languages = impl->Languages;
|
iface.Languages = impl->Languages;
|
||||||
|
@ -6558,7 +6558,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
|
||||||
iface.ImplementationIsInterface = true;
|
iface.ImplementationIsInterface = true;
|
||||||
iface.Libraries = impl->Libraries;
|
iface.Libraries = impl->Libraries;
|
||||||
iface.WrongConfigLibraries = impl->WrongConfigLibraries;
|
iface.WrongConfigLibraries = impl->WrongConfigLibraries;
|
||||||
if(this->GetType() == cmTarget::STATIC_LIBRARY)
|
if(this->LinkLanguagePropagatesToDependents())
|
||||||
{
|
{
|
||||||
// Targets using this archive need its language runtime libraries.
|
// Targets using this archive need its language runtime libraries.
|
||||||
iface.Languages = impl->Languages;
|
iface.Languages = impl->Languages;
|
||||||
|
|
|
@ -549,6 +549,9 @@ public:
|
||||||
|
|
||||||
void FinalizeSystemIncludeDirectories();
|
void FinalizeSystemIncludeDirectories();
|
||||||
|
|
||||||
|
bool LinkLanguagePropagatesToDependents() const
|
||||||
|
{ return this->TargetTypeValue == STATIC_LIBRARY; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The set of include directories that are marked as system include
|
// The set of include directories that are marked as system include
|
||||||
// directories.
|
// directories.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
add_library(foo SHARED empty.cpp)
|
add_library(foo STATIC empty.cpp)
|
||||||
add_library(bar SHARED empty.cpp)
|
add_library(bar STATIC empty.cpp)
|
||||||
target_link_libraries(foo $<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,anything>:bar>)
|
target_link_libraries(foo $<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,anything>:bar>)
|
||||||
|
|
Loading…
Reference in New Issue