Commit 6269133d authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - adopted CMake files to be portable

parent efc9404e
......@@ -8,8 +8,13 @@ ADD_SUBDIRECTORY( constraints )
ADD_SUBDIRECTORY( math )
ADD_LIBRARY( common ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC} ${FIBERSIMILARITY_SRC} )
TARGET_LINK_LIBRARIES( common ${Boost_LIBRARIES} "dl" )
TARGET_LINK_LIBRARIES( common ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
# Set the prefix and suffix of dynamically loadable modules to match
# CMAKEs naming of them. The quotes are necessary so the shell doesn't mess
# with these defines.
add_definitions( '-DW_LIB_PREFIX="${CMAKE_SHARED_MODULE_PREFIX}"' )
add_definitions( '-DW_LIB_SUFFIX="${CMAKE_SHARED_MODULE_SUFFIX}"' )
# Unit tests
IF( OW_COMPILE_TESTS )
......
......@@ -263,3 +263,14 @@ void* WSharedLib::findVariable( const std::string& name ) const
{
return m_data->findVariable( name );
}
std::string WSharedLib::getSystemPrefix()
{
return W_LIB_PREFIX;
}
std::string WSharedLib::getSystemSuffix()
{
return W_LIB_SUFFIX;
}
......@@ -110,6 +110,20 @@ public:
template < typename PtrType >
void fetchVariable( const std::string& name, PtrType& variable ) const;
/**
* Returns the prefix used for libraries on the system. On Unix this mostly is "lib".
*
* \return the prefix.
*/
static std::string getSystemPrefix();
/**
* Returns the suffix for libraries used on the system. On Unix this mostly is "so", Windows uses "dll" and Mac something like "dylib".
*
* \return the suffix.
*/
static std::string getSystemSuffix();
protected:
private:
......
......@@ -51,9 +51,7 @@ void WModuleLoader::load( WSharedAssociativeContainer< std::set< boost::shared_p
i != boost::filesystem::directory_iterator(); ++i )
{
std::string suffix = wiotools::getSuffix( i->leaf() );
if( !boost::filesystem::is_directory( *i ) &&
( ( suffix == ".so" ) || ( suffix == ".dll" ) || ( suffix == ".dylib" ) )
) // This prefix has been defined by our build system
if( !boost::filesystem::is_directory( *i ) && ( suffix == WSharedLib::getSystemSuffix() ) )
{
try
{
......@@ -70,14 +68,14 @@ void WModuleLoader::load( WSharedAssociativeContainer< std::set< boost::shared_p
// could the prototype be created?
if( !m )
{
WLogger::getLogger()->addLogMessage( "Load failed for module \"" + i->path().native_file_string() + "\". Could not create " +
WLogger::getLogger()->addLogMessage( "Load failed for module \"" + i->leaf() + "\". Could not create " +
"prototype instance.", "Module Loader", LL_ERROR );
continue;
}
else
{
// yes, add it to the list of prototypes
WLogger::getLogger()->addLogMessage( "Loaded " + i->path().native_file_string(), "Module Loader", LL_INFO );
WLogger::getLogger()->addLogMessage( "Loaded " + i->leaf(), "Module Loader", LL_INFO );
ticket->get().insert( m );
m_libs.push_back( l );
}
......@@ -86,7 +84,7 @@ void WModuleLoader::load( WSharedAssociativeContainer< std::set< boost::shared_p
}
catch( const WException& e )
{
WLogger::getLogger()->addLogMessage( "Load failed for module \"" + i->path().native_file_string() + "\". " + e.what() + ". Ignoring.",
WLogger::getLogger()->addLogMessage( "Load failed for module \"" + i->leaf() + "\". " + e.what() + ". Ignoring.",
"Module Loader", LL_ERROR );
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment