Fix soname in cross-compiled targets with Mac host (#11547)

The soname generation code was compile-time selected instead of runtime
selected.  The result is that a Mac-compiled cmake used to cross-compile
Mac -> Unix generates an soname of the form libfoo.x.y.so instead of
libfoo.so.x.y as expected.  Instead do a runtime check based on the
target platform.

Inspired-By: George Staikos <staikos@kde.org>
This commit is contained in:
Brad King 2010-12-09 11:18:25 -05:00
parent d25638ac05
commit 3b7f901494
1 changed files with 24 additions and 15 deletions

View File

@ -3196,6 +3196,7 @@ void cmTarget::GetLibraryNames(std::string& name,
// the library version as the soversion. // the library version as the soversion.
soversion = version; soversion = version;
} }
bool isApple = this->Makefile->IsOn("APPLE");
// Get the components of the library name. // Get the components of the library name.
std::string prefix; std::string prefix;
@ -3207,26 +3208,33 @@ void cmTarget::GetLibraryNames(std::string& name,
name = prefix+base+suffix; name = prefix+base+suffix;
// The library's soname. // The library's soname.
#if defined(__APPLE__) if(isApple)
{
soName = prefix+base; soName = prefix+base;
#else }
else
{
soName = name; soName = name;
#endif }
if(soversion) if(soversion)
{ {
soName += "."; soName += ".";
soName += soversion; soName += soversion;
} }
#if defined(__APPLE__) if(isApple)
{
soName += suffix; soName += suffix;
#endif }
// The library's real name on disk. // The library's real name on disk.
#if defined(__APPLE__) if(isApple)
{
realName = prefix+base; realName = prefix+base;
#else }
else
{
realName = name; realName = name;
#endif }
if(version) if(version)
{ {
realName += "."; realName += ".";
@ -3237,9 +3245,10 @@ void cmTarget::GetLibraryNames(std::string& name,
realName += "."; realName += ".";
realName += soversion; realName += soversion;
} }
#if defined(__APPLE__) if(isApple)
{
realName += suffix; realName += suffix;
#endif }
// The import library name. // The import library name.
if(this->GetType() == cmTarget::SHARED_LIBRARY || if(this->GetType() == cmTarget::SHARED_LIBRARY ||