From 847c8403fe23e241d7fd3a7478790938afc24a9e Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 4 Feb 2008 15:22:10 -0500 Subject: [PATCH] BUG: Added TARGET_ARCHIVES_MAY_BE_SHARED_LIBS global property to help compute proper rpath information on AIX when shared libraries have names like "libfoo.a". --- Modules/Platform/AIX.cmake | 3 +++ Source/cmComputeLinkInformation.cxx | 23 +++++++++++++++++++++-- Source/cmComputeLinkInformation.h | 3 +++ Source/cmake.cxx | 7 +++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Modules/Platform/AIX.cmake b/Modules/Platform/AIX.cmake index d6b6af0129..455586d4fd 100644 --- a/Modules/Platform/AIX.cmake +++ b/Modules/Platform/AIX.cmake @@ -12,6 +12,9 @@ SET(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH /usr/lib /lib) SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-blibpath:") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") +# Files named "libfoo.a" may actually be shared libraries. +SET_PROPERTY(GLOBAL PROPERTY TARGET_ARCHIVES_MAY_BE_SHARED_LIBS 1) + # CXX Compiler IF(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -Wl,-G") # -shared diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index b079f9d75a..10a0653793 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -23,6 +23,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmake.h" #include @@ -222,6 +223,7 @@ cmComputeLinkInformation this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = this->Makefile->GetLocalGenerator(); this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); + this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->Config = config; @@ -649,6 +651,11 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, //---------------------------------------------------------------------------- void cmComputeLinkInformation::ComputeLinkTypeInfo() { + // Check whether archives may actually be shared libraries. + this->ArchivesMayBeShared = + this->CMakeInstance->GetPropertyAsBool( + "TARGET_ARCHIVES_MAY_BE_SHARED_LIBS"); + // First assume we cannot do link type stuff. this->LinkTypeEnabled = false; @@ -1260,8 +1267,20 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, std::string file = cmSystemTools::GetFilenameName(fullPath); if(!this->ExtractSharedLibraryName.find(file.c_str())) { - // This is not the name of a shared library. - return; + // On some platforms (AIX) a shared library may look static. + if(this->ArchivesMayBeShared) + { + if(!this->ExtractStaticLibraryName.find(file.c_str())) + { + // This is not the name of a shared library or archive. + return; + } + } + else + { + // This is not the name of a shared library. + return; + } } // Include this library in the runtime path ordering. diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index c5f3778936..be3275c9f6 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -21,6 +21,7 @@ #include +class cmake; class cmGlobalGenerator; class cmLocalGenerator; class cmMakefile; @@ -79,6 +80,7 @@ private: cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; cmGlobalGenerator* GlobalGenerator; + cmake* CMakeInstance; // Configuration information. const char* Config; @@ -114,6 +116,7 @@ private: std::string SharedLinkTypeFlag; bool LinkTypeEnabled; void SetCurrentLinkType(LinkType lt); + bool ArchivesMayBeShared; // Link item parsing. void ComputeItemParserInfo(); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b5bf0dcdbc..271a6b62d7 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -3245,6 +3245,13 @@ void cmake::DefineProperties(cmake *cm) "platform supports shared libraries. Basically all current general " "general purpose OS do so, the exception are usually embedded systems " "with no or special OSs."); + + cm->DefineProperty + ("TARGET_ARCHIVES_MAY_BE_SHARED_LIBS", cmProperty::GLOBAL, + "Set if shared libraries may be named like archives.", + "On AIX shared libraries may be named \"lib.a\". " + "This property is set to true on such platforms."); + cm->DefineProperty ("FIND_LIBRARY_USE_LIB64_PATHS", cmProperty::GLOBAL, "Whether FIND_LIBRARY should automatically search lib64 directories.",