diff options
author | Brad King <brad.king@kitware.com> | 2011-03-08 19:22:20 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2011-03-08 19:22:20 (GMT) |
commit | 27b41deaed762621a0dcff31c5cce5cc7c5624c8 (patch) | |
tree | e8c187c3333982b9ce2d03cbb8786dec7a054e6f /Source | |
parent | b665d2f08a663a4d97cef179d3dc7f592688cea7 (diff) | |
parent | 077954d4cbd0d2f8b8ae96964bfe5c9747934fe8 (diff) | |
download | CMake-27b41deaed762621a0dcff31c5cce5cc7c5624c8.zip CMake-27b41deaed762621a0dcff31c5cce5cc7c5624c8.tar.gz CMake-27b41deaed762621a0dcff31c5cce5cc7c5624c8.tar.bz2 |
Merge topic 'link-static'
077954d Test static linking with LINK_SEARCH_START_STATIC
5abfb57 Add target property LINK_SEARCH_START_STATIC to aid static linking
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 6 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 31 |
2 files changed, 26 insertions, 11 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index d53200c..e3c33a2 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -817,9 +817,9 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() this->SharedLinkTypeFlag = shared_link_type_flag; } - // TODO: Lookup the starting link type from the target (is it being - // linked statically?). - this->StartLinkType = LinkShared; + // Lookup the starting link type from the target (linked statically?). + const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 75ff712..0ca46c4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -487,17 +487,32 @@ void cmTarget::DefineProperties(cmake *cm) "Per-configuration linker flags for a target.", "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 ("LINK_SEARCH_END_STATIC", cmProperty::TARGET, "End a link line such that static system libraries are used.", - "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. By default the " - "linker search type is left at -Bdynamic by the end of the library " - "list. This property switches the final linker search type to " - "-Bstatic."); + CM_LINK_SEARCH_SUMMARY + "By default CMake adds an option at the end of the library list (if " + "necessary) to set the linker search type back to its starting type. " + "This property switches the final linker search type to -Bstatic " + "regardless of how it started. " + "See also LINK_SEARCH_START_STATIC."); cm->DefineProperty ("LINKER_LANGUAGE", cmProperty::TARGET, |