Skip to content
Snippets Groups Projects
Commit d45f35b7 authored by Atkins, Charles Vernon's avatar Atkins, Charles Vernon Committed by GitHub
Browse files

Merge pull request #78 from chuckatkins/fix-dataman-libsearch

Fix dataman libsearch
parents bbe96fb1 d6b2e378
No related branches found
No related tags found
No related merge requests found
......@@ -3,18 +3,26 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
set(dataman_targets)
add_library(dataman
DataManBase.h DataManBase.cpp
DataMan.h DataMan.cpp
)
target_include_directories(dataman PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(dataman PRIVATE adios2sys)
list(APPEND dataman_targets dataman)
# Add the dataman plugins as MODULE libraries instead of SHARED libraries.
# MODULE libraries are designed to be plugins, i.e. shared libs that nobody
# else links to.
add_library(cacheman SHARED CacheMan.h CacheMan.cpp)
add_library(cacheman MODULE CacheMan.h CacheMan.cpp)
target_link_libraries(cacheman PRIVATE dataman)
list(APPEND dataman_targets cacheman)
install(
TARGETS dataman cacheman EXPORT adios2
TARGETS ${dataman_targets} EXPORT adios2
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
......
......@@ -18,19 +18,62 @@ struct DataManBase::ManagerLibrary
{
adios2sys::DynamicLoader::LibraryHandle m_LibraryHandle;
DataManBase *(*m_getManFunc)();
ManagerLibrary(std::string method)
{
std::stringstream libNameBuilder;
libNameBuilder << adios2sys::DynamicLoader::LibPrefix() << method
<< "man" << adios2sys::DynamicLoader::LibExtension();
std::string libName = libNameBuilder.str();
std::vector<std::string> searchedLibs;
std::string libName;
std::vector<std::string> libPrefixes;
libPrefixes.emplace_back("");
libPrefixes.emplace_back("lib");
#ifdef __CYGWIN__
libPrefixes.emplace_back("cyg");
#endif
std::vector<std::string> libSuffixes;
#ifdef __APPLE__
libSuffixes.emplace_back("man.dylib");
libSuffixes.emplace_back("man.so");
#endif
#ifdef __hpux
libSuffixes.emplace_back("man.sl");
#endif
#ifdef __unix__
libSuffixes.emplace_back("man.so");
#endif
#ifdef _WIN32
libSuffixes.emplace_back("man.dll");
#endif
// Bind to the dynamic library
m_LibraryHandle = adios2sys::DynamicLoader::OpenLibrary(libName);
// Test the various combinations of library names
for (const std::string &prefix : libPrefixes)
{
for (const std::string &suffix : libSuffixes)
{
libName = prefix + method + suffix;
m_LibraryHandle =
adios2sys::DynamicLoader::OpenLibrary(libName);
searchedLibs.push_back(libName);
if (m_LibraryHandle)
{
break;
}
}
if (m_LibraryHandle)
{
break;
}
}
if (!m_LibraryHandle)
{
throw std::runtime_error("Unable to locate the " + libName +
" library.");
std::stringstream errString;
errString << "Unable to locate the " << method << " manager "
<< "library; searched for ";
std::copy(searchedLibs.begin(), searchedLibs.end(),
std::ostream_iterator<std::string>(errString, " "));
throw std::runtime_error(errString.str());
}
// Bind to the getMan symbol
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment