summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-06-10 13:26:32 (GMT)
committerBrad King <brad.king@kitware.com>2010-06-10 13:26:32 (GMT)
commit3f929475246a3d89ca5d4c5db301d1c4705d0d69 (patch)
treef43ad9b08efa78e36be97f6b89eb02346ce8522c /Source/kwsys
parentc452d5b646183f665cabdfc8b85c899217cd2118 (diff)
downloadCMake-3f929475246a3d89ca5d4c5db301d1c4705d0d69.zip
CMake-3f929475246a3d89ca5d4c5db301d1c4705d0d69.tar.gz
CMake-3f929475246a3d89ca5d4c5db301d1c4705d0d69.tar.bz2
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.
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/CMakeLists.txt8
-rw-r--r--Source/kwsys/DynamicLoader.cxx84
-rw-r--r--Source/kwsys/DynamicLoader.hxx.in8
3 files changed, 12 insertions, 88 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 62042e8..f440ff9 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -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)
diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx
index 58e02c7..c4ee095 100644
--- a/Source/kwsys/DynamicLoader.cxx
+++ b/Source/kwsys/DynamicLoader.cxx
@@ -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
@@ -176,21 +163,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
}
//----------------------------------------------------------------------------
-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()
{
return 0;
@@ -285,22 +257,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
}
//----------------------------------------------------------------------------
-const char* DynamicLoader::LibPrefix()
-{
-#ifdef __MINGW32__
- return "lib";
-#else
- return "";
-#endif
-}
-
-//----------------------------------------------------------------------------
-const char* DynamicLoader::LibExtension()
-{
- return ".dll";
-}
-
-//----------------------------------------------------------------------------
const char* DynamicLoader::LastError()
{
LPVOID lpMsgBuf=NULL;
@@ -418,18 +374,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
}
//----------------------------------------------------------------------------
-const char* DynamicLoader::LibPrefix()
-{
- return "lib";
-}
-
-//----------------------------------------------------------------------------
-const char* DynamicLoader::LibExtension()
-{
- return ".so";
-}
-
-//----------------------------------------------------------------------------
const char* DynamicLoader::LastError()
{
const char *retval = strerror(last_dynamic_err);
@@ -476,18 +420,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
}
//----------------------------------------------------------------------------
-const char* DynamicLoader::LibPrefix()
- {
- return "lib";
- }
-
-//----------------------------------------------------------------------------
-const char* DynamicLoader::LibExtension()
- {
- return ".a";
- }
-
-//----------------------------------------------------------------------------
const char* DynamicLoader::LastError()
{
return "General error";
@@ -540,22 +472,6 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
}
//----------------------------------------------------------------------------
-const char* DynamicLoader::LibPrefix()
-{
- return "lib";
-}
-
-//----------------------------------------------------------------------------
-const char* DynamicLoader::LibExtension()
-{
-#ifdef __CYGWIN__
- return ".dll";
-#else
- return ".so";
-#endif
-}
-
-//----------------------------------------------------------------------------
const char* DynamicLoader::LastError()
{
return dlerror();
diff --git a/Source/kwsys/DynamicLoader.hxx.in b/Source/kwsys/DynamicLoader.hxx.in
index 325e956..64468ec 100644
--- a/Source/kwsys/DynamicLoader.hxx.in
+++ b/Source/kwsys/DynamicLoader.hxx.in
@@ -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();