KWSys: Configure DynamicLoader library prefix/suffix

The DynamicLoader::LibPrefix and DynamicLoader::LibExtension methods
previously hard-coded the module name components for each platform.  Set
them from the CMAKE_SHARED_MODULE_PREFIX and CMAKE_SHARED_MODULE_SUFFIX
CMake variables instead.  This ensures consistency in a program that
uses these methods to construct the file names for its own modules.
This commit is contained in:
Brad King 2010-06-10 09:26:32 -04:00
parent c452d5b646
commit 3f92947524
3 changed files with 12 additions and 88 deletions

View File

@ -309,6 +309,14 @@ IF(NOT KWSYS_IN_SOURCE_BUILD)
${PROJECT_BINARY_DIR}/kwsysPrivate.h COPY_ONLY IMMEDIATE)
ENDIF(NOT KWSYS_IN_SOURCE_BUILD)
# Select plugin module file name convention.
IF(NOT KWSYS_DynamicLoader_PREFIX)
SET(KWSYS_DynamicLoader_PREFIX ${CMAKE_SHARED_MODULE_PREFIX})
ENDIF()
IF(NOT KWSYS_DynamicLoader_SUFFIX)
SET(KWSYS_DynamicLoader_SUFFIX ${CMAKE_SHARED_MODULE_SUFFIX})
ENDIF()
#-----------------------------------------------------------------------------
# We require ANSI support from the C compiler. Add any needed flags.
IF(CMAKE_ANSI_CFLAGS)

View File

@ -69,19 +69,6 @@ DynamicLoader::GetSymbolAddress(DynamicLoader::LibraryHandle lib, const char* sy
return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibPrefix()
{
return "lib";
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibExtension()
{
return ".sl";
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LastError()
{
// TODO: Need implementation with errno/strerror
@ -175,21 +162,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibPrefix()
{
return "lib";
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibExtension()
{
// NSCreateObjectFileImageFromFile fail when dealing with dylib image
// it returns NSObjectFileImageInappropriateFile
//return ".dylib";
return ".so";
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LastError()
{
@ -284,22 +256,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
#endif
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibPrefix()
{
#ifdef __MINGW32__
return "lib";
#else
return "";
#endif
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibExtension()
{
return ".dll";
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LastError()
{
@ -417,18 +373,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
return result.psym;
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibPrefix()
{
return "lib";
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibExtension()
{
return ".so";
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LastError()
{
@ -475,18 +419,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
return 0;
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibPrefix()
{
return "lib";
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibExtension()
{
return ".a";
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LastError()
{
@ -539,22 +471,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
return result.psym;
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibPrefix()
{
return "lib";
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LibExtension()
{
#ifdef __CYGWIN__
return ".dll";
#else
return ".so";
#endif
}
//----------------------------------------------------------------------------
const char* DynamicLoader::LastError()
{

View File

@ -86,11 +86,11 @@ public:
/** Find the address of the symbol in the given library. */
static SymbolPointer GetSymbolAddress(LibraryHandle, const char*);
/** Return the library prefix for the given architecture */
static const char* LibPrefix();
/** Return the default module prefix for the current platform. */
static const char* LibPrefix() { return "@KWSYS_DynamicLoader_PREFIX@"; }
/** Return the library extension for the given architecture. */
static const char* LibExtension();
/** Return the default module suffix for the current platform. */
static const char* LibExtension() { return "@KWSYS_DynamicLoader_SUFFIX@"; }
/** Return the last error produced from a calls made on this class. */
static const char* LastError();