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:
parent
c452d5b646
commit
3f92947524
|
@ -309,6 +309,14 @@ IF(NOT KWSYS_IN_SOURCE_BUILD)
|
||||||
${PROJECT_BINARY_DIR}/kwsysPrivate.h COPY_ONLY IMMEDIATE)
|
${PROJECT_BINARY_DIR}/kwsysPrivate.h COPY_ONLY IMMEDIATE)
|
||||||
ENDIF(NOT KWSYS_IN_SOURCE_BUILD)
|
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.
|
# We require ANSI support from the C compiler. Add any needed flags.
|
||||||
IF(CMAKE_ANSI_CFLAGS)
|
IF(CMAKE_ANSI_CFLAGS)
|
||||||
|
|
|
@ -69,19 +69,6 @@ DynamicLoader::GetSymbolAddress(DynamicLoader::LibraryHandle lib, const char* sy
|
||||||
return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
|
return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LibPrefix()
|
|
||||||
{
|
|
||||||
return "lib";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LibExtension()
|
|
||||||
{
|
|
||||||
return ".sl";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LastError()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
// TODO: Need implementation with errno/strerror
|
// TODO: Need implementation with errno/strerror
|
||||||
|
@ -175,21 +162,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
|
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()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
|
@ -284,22 +256,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LibPrefix()
|
|
||||||
{
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
return "lib";
|
|
||||||
#else
|
|
||||||
return "";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LibExtension()
|
|
||||||
{
|
|
||||||
return ".dll";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* DynamicLoader::LastError()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
|
@ -417,18 +373,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
return result.psym;
|
return result.psym;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LibPrefix()
|
|
||||||
{
|
|
||||||
return "lib";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LibExtension()
|
|
||||||
{
|
|
||||||
return ".so";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* DynamicLoader::LastError()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
|
@ -475,18 +419,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LibPrefix()
|
|
||||||
{
|
|
||||||
return "lib";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* DynamicLoader::LibExtension()
|
|
||||||
{
|
|
||||||
return ".a";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* DynamicLoader::LastError()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
|
@ -539,22 +471,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
|
||||||
return result.psym;
|
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()
|
const char* DynamicLoader::LastError()
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,11 +86,11 @@ public:
|
||||||
/** Find the address of the symbol in the given library. */
|
/** Find the address of the symbol in the given library. */
|
||||||
static SymbolPointer GetSymbolAddress(LibraryHandle, const char*);
|
static SymbolPointer GetSymbolAddress(LibraryHandle, const char*);
|
||||||
|
|
||||||
/** Return the library prefix for the given architecture */
|
/** Return the default module prefix for the current platform. */
|
||||||
static const char* LibPrefix();
|
static const char* LibPrefix() { return "@KWSYS_DynamicLoader_PREFIX@"; }
|
||||||
|
|
||||||
/** Return the library extension for the given architecture. */
|
/** Return the default module suffix for the current platform. */
|
||||||
static const char* LibExtension();
|
static const char* LibExtension() { return "@KWSYS_DynamicLoader_SUFFIX@"; }
|
||||||
|
|
||||||
/** Return the last error produced from a calls made on this class. */
|
/** Return the last error produced from a calls made on this class. */
|
||||||
static const char* LastError();
|
static const char* LastError();
|
||||||
|
|
Loading…
Reference in New Issue