Add target property LINK_SEARCH_START_STATIC to aid static linking
Commit afd7d4ca
(Add target property LINK_SEARCH_END_STATIC, 2008-01-31)
defined a property to ensure that static runtime libraries get selected.
Add a property to specify that all libraries whose type is unknown, such
as "-lm", should be assumed static. Furthermore it assumes that an
option such as "-static" is also used so that no initial -Bstatic is
needed.
This commit is contained in:
parent
cbb5ae60be
commit
5abfb57184
|
@ -817,9 +817,9 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
|
||||||
this->SharedLinkTypeFlag = shared_link_type_flag;
|
this->SharedLinkTypeFlag = shared_link_type_flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Lookup the starting link type from the target (is it being
|
// Lookup the starting link type from the target (linked statically?).
|
||||||
// linked statically?).
|
const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC");
|
||||||
this->StartLinkType = LinkShared;
|
this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared;
|
||||||
this->CurrentLinkType = this->StartLinkType;
|
this->CurrentLinkType = this->StartLinkType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -487,17 +487,32 @@ void cmTarget::DefineProperties(cmake *cm)
|
||||||
"Per-configuration linker flags for a target.",
|
"Per-configuration linker flags for a target.",
|
||||||
"This is the configuration-specific version of LINK_FLAGS.");
|
"This is the configuration-specific version of LINK_FLAGS.");
|
||||||
|
|
||||||
|
#define CM_LINK_SEARCH_SUMMARY \
|
||||||
|
"Some linkers support switches such as -Bstatic and -Bdynamic " \
|
||||||
|
"to determine whether to use static or shared libraries for -lXXX " \
|
||||||
|
"options. CMake uses these options to set the link type for " \
|
||||||
|
"libraries whose full paths are not known or (in some cases) are in " \
|
||||||
|
"implicit link directories for the platform. "
|
||||||
|
|
||||||
|
cm->DefineProperty
|
||||||
|
("LINK_SEARCH_START_STATIC", cmProperty::TARGET,
|
||||||
|
"Assume the linker looks for static libraries by default.",
|
||||||
|
CM_LINK_SEARCH_SUMMARY
|
||||||
|
"By default the linker search type is assumed to be -Bdynamic at "
|
||||||
|
"the beginning of the library list. This property switches the "
|
||||||
|
"assumption to -Bstatic. It is intended for use when linking an "
|
||||||
|
"executable statically (e.g. with the GNU -static option). "
|
||||||
|
"See also LINK_SEARCH_END_STATIC.");
|
||||||
|
|
||||||
cm->DefineProperty
|
cm->DefineProperty
|
||||||
("LINK_SEARCH_END_STATIC", cmProperty::TARGET,
|
("LINK_SEARCH_END_STATIC", cmProperty::TARGET,
|
||||||
"End a link line such that static system libraries are used.",
|
"End a link line such that static system libraries are used.",
|
||||||
"Some linkers support switches such as -Bstatic and -Bdynamic "
|
CM_LINK_SEARCH_SUMMARY
|
||||||
"to determine whether to use static or shared libraries for -lXXX "
|
"By default CMake adds an option at the end of the library list (if "
|
||||||
"options. CMake uses these options to set the link type for "
|
"necessary) to set the linker search type back to its starting type. "
|
||||||
"libraries whose full paths are not known or (in some cases) are in "
|
"This property switches the final linker search type to -Bstatic "
|
||||||
"implicit link directories for the platform. By default the "
|
"regardless of how it started. "
|
||||||
"linker search type is left at -Bdynamic by the end of the library "
|
"See also LINK_SEARCH_START_STATIC.");
|
||||||
"list. This property switches the final linker search type to "
|
|
||||||
"-Bstatic.");
|
|
||||||
|
|
||||||
cm->DefineProperty
|
cm->DefineProperty
|
||||||
("LINKER_LANGUAGE", cmProperty::TARGET,
|
("LINKER_LANGUAGE", cmProperty::TARGET,
|
||||||
|
|
Loading…
Reference in New Issue