From 08a72abe2516849345c0fc6dcff4aaeb83d7a2cc Mon Sep 17 00:00:00 2001 From: geert Date: Tue, 17 Jan 2017 16:35:42 +0100 Subject: [PATCH] Fixes for file format plugins on Linux --- CMakeLists.txt | 4 +++- cmakemodules/FindOPENSLIDE.cmake | 2 +- cmakemodules/FindUNITTEST.cmake | 3 ++- config/ASAPMacros.h.in | 6 +++--- imgproc/NucleiSegmentation/CMakeLists.txt | 2 +- imgproc/wholeslide/CMakeLists.txt | 2 +- io/multiresolutionimageinterface/CMakeLists.txt | 2 +- .../MultiResolutionImage.h | 2 +- .../MultiResolutionImageFactory.cpp | 17 +++++++++++++++-- io/multiresolutionimageinterface/VSIImage.cpp | 3 ++- 10 files changed, 30 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21c28691..bbea5357 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ IF(NOT WIN32) SET(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib:$ORIGIN/") ENDIF(NOT WIN32) +set (CMAKE_CXX_STANDARD 11) + # Set compile definitions to ignore some warnings if (WIN32) set(DEFAULT_COMPILE_DEFINITIONS ${DEFAULT_COMPILE_DEFINITIONS} @@ -146,4 +148,4 @@ set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "ASAP - Automated Slide Analysis Platform") set(CPACK_PACKAGING_INSTALL_PREFIX /opt/ASAP) ENDIF(WIN32) INCLUDE(CPack) -ENDIF(PACKAGE_ON_INSTALL) \ No newline at end of file +ENDIF(PACKAGE_ON_INSTALL) diff --git a/cmakemodules/FindOPENSLIDE.cmake b/cmakemodules/FindOPENSLIDE.cmake index 0ec0a591..dde9a629 100644 --- a/cmakemodules/FindOPENSLIDE.cmake +++ b/cmakemodules/FindOPENSLIDE.cmake @@ -6,7 +6,7 @@ # OPENSLIDE_FOUND, If false, do not try to use OPENSLIDE. find_path(OPENSLIDE_INCLUDE_DIR openslide.h) -find_library(OPENSLIDE_LIBRARY NAMES OPENSLIDE) +find_library(OPENSLIDE_LIBRARY NAMES openslide) # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if # all listed variables are TRUE diff --git a/cmakemodules/FindUNITTEST.cmake b/cmakemodules/FindUNITTEST.cmake index 8913c355..6a06d604 100644 --- a/cmakemodules/FindUNITTEST.cmake +++ b/cmakemodules/FindUNITTEST.cmake @@ -9,12 +9,13 @@ find_path(UNITTEST_INCLUDE_DIR UnitTest++.h) find_library(UNITTEST_LIBRARY NAMES UNITTEST) +find_library(UNITTEST_LIBRARY_DEBUG NAMES UNITTEST) # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if # all listed variables are TRUE include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(UNITTEST - REQUIRED_VARS UNITTEST_LIBRARY UNITTEST_INCLUDE_DIR) + REQUIRED_VARS UNITTEST_LIBRARY UNITTEST_LIBRARY_DEBUG UNITTEST_INCLUDE_DIR) if(UNITTEST_FOUND) set( UNITTEST_LIBRARIES ${UNITTEST_LIBRARY} ) diff --git a/config/ASAPMacros.h.in b/config/ASAPMacros.h.in index 393022a8..1af8b643 100644 --- a/config/ASAPMacros.h.in +++ b/config/ASAPMacros.h.in @@ -9,9 +9,9 @@ #ifndef __ASAPMACROS_H__ #define __ASAPMACROS_H__ -#define ASAP_MAJOR_VERSION = @CURRENT_MAJOR_VERSION@ -#define ASAP_MINOR_VERSION = @CURRENT_MINOR_VERSION@ -#define ASAP_PATCH_VERSION = @CURRENT_PATCH_VERSION@ +#define ASAP_MAJOR_VERSION @CURRENT_MAJOR_VERSION@ +#define ASAP_MINOR_VERSION @CURRENT_MINOR_VERSION@ +#define ASAP_PATCH_VERSION @CURRENT_PATCH_VERSION@ static const char* ASAP_VERSION_STRING = "@CURRENT_MAJOR_VERSION@.@CURRENT_MINOR_VERSION@.@CURRENT_PATCH_VERSION@"; #ifdef __WIN32__ diff --git a/imgproc/NucleiSegmentation/CMakeLists.txt b/imgproc/NucleiSegmentation/CMakeLists.txt index 1cda957e..e94c1456 100644 --- a/imgproc/NucleiSegmentation/CMakeLists.txt +++ b/imgproc/NucleiSegmentation/CMakeLists.txt @@ -33,4 +33,4 @@ INSTALL(TARGETS NucleiSegmentation ) INSTALL(FILES FRST.h DESTINATION include/imgproc/NucleiSegmentation) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/NucleiSegmentation_export.h DESTINATION include/imgproc/NucleiSegmentation) \ No newline at end of file +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/nucleisegmentation_export.h DESTINATION include/imgproc/NucleiSegmentation) \ No newline at end of file diff --git a/imgproc/wholeslide/CMakeLists.txt b/imgproc/wholeslide/CMakeLists.txt index de58d583..fb8f2e76 100644 --- a/imgproc/wholeslide/CMakeLists.txt +++ b/imgproc/wholeslide/CMakeLists.txt @@ -73,7 +73,7 @@ IF(WRAP_WHOLESLIDEFILTERS_PYTHON) set_source_files_properties(wholeslidefilters.i PROPERTIES CPLUSPLUS ON) set_source_files_properties(wholeslidefilters.i PROPERTIES SWIG_FLAGS "-builtin") - include_directories(. ${PYTHON_INCLUDE_DIR} ${DIAGPathology_BINARY_DIR}) + include_directories(. ${PYTHON_INCLUDE_DIR} ${DIAGPathology_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) SWIG_ADD_MODULE(wholeslidefilters python wholeslidefilters.i) SWIG_LINK_LIBRARIES(wholeslidefilters wholeslidefilters core) SWIG_LINK_LIBRARIES(wholeslidefilters ${PYTHON_LIBRARIES} ${PYTHON_DEBUG_LIBRARIES}) diff --git a/io/multiresolutionimageinterface/CMakeLists.txt b/io/multiresolutionimageinterface/CMakeLists.txt index 7c5ec97c..e408efa7 100644 --- a/io/multiresolutionimageinterface/CMakeLists.txt +++ b/io/multiresolutionimageinterface/CMakeLists.txt @@ -139,6 +139,6 @@ INSTALL(TARGETS multiresolutionimageinterface INSTALL(TARGETS openslidefileformat EXPORT asap-targets RUNTIME DESTINATION bin/formats - LIBRARY DESTINATION lib + LIBRARY DESTINATION bin/formats ARCHIVE DESTINATION lib ) \ No newline at end of file diff --git a/io/multiresolutionimageinterface/MultiResolutionImage.h b/io/multiresolutionimageinterface/MultiResolutionImage.h index b9d96d76..ed51b2ed 100644 --- a/io/multiresolutionimageinterface/MultiResolutionImage.h +++ b/io/multiresolutionimageinterface/MultiResolutionImage.h @@ -156,4 +156,4 @@ template <> void MULTIRESOLUTIONIMAGEINTERFACE_EXPORT MultiResolutionImage::getR template <> void MULTIRESOLUTIONIMAGEINTERFACE_EXPORT MultiResolutionImage::getRawRegion(const long long& startX, const long long& startY, const unsigned long long& width, const unsigned long long& height, const unsigned int& level, float*& data); -#endif \ No newline at end of file +#endif diff --git a/io/multiresolutionimageinterface/MultiResolutionImageFactory.cpp b/io/multiresolutionimageinterface/MultiResolutionImageFactory.cpp index 3373c861..94c75943 100644 --- a/io/multiresolutionimageinterface/MultiResolutionImageFactory.cpp +++ b/io/multiresolutionimageinterface/MultiResolutionImageFactory.cpp @@ -65,13 +65,18 @@ void MultiResolutionImageFactory::registerExternalFileFormats() { pathStr = std::string(path); #else Dl_info dlInfo; - dladdr(&MultiResolutionImageFactory::registerExternalFileFormats, &dlInfo); + dladdr((void*)&MultiResolutionImageFactory::registerExternalFileFormats, &dlInfo); pathStr = std::string(dlInfo.dli_fname); #endif std::string rootDir = core::extractFilePath(pathStr); - std::string fileFormatPluginDir = core::completePath("formats", rootDir); std::vector formatPlugins; +#ifdef _WIN32 + std::string fileFormatPluginDir = core::completePath("formats", rootDir); core::getFiles(fileFormatPluginDir, "*.dll", formatPlugins); +#else + std::string fileFormatPluginDir = core::completePath("bin/formats", core::upOneLevel(rootDir)); + core::getFiles(fileFormatPluginDir, "*.so", formatPlugins); +#endif for (std::vector::const_iterator it = formatPlugins.begin(); it != formatPlugins.end(); ++it) { #ifdef _WIN32 SetDllDirectory(rootDir.c_str()); @@ -85,6 +90,14 @@ void MultiResolutionImageFactory::registerExternalFileFormats() { else { DWORD test = GetLastError(); } +#else + void *hndl = dlopen(core::completePath((*it), fileFormatPluginDir).c_str(), RTLD_NOW); + if(hndl != NULL){ + FileFormatLoader loadfunction = (FileFormatLoader)dlsym(hndl, "filetypeLoad"); + if (loadfunction) { + (*loadfunction)(); + } + } #endif } MultiResolutionImageFactory::_externalFormatsRegistered = true; diff --git a/io/multiresolutionimageinterface/VSIImage.cpp b/io/multiresolutionimageinterface/VSIImage.cpp index f5a67af5..a6347657 100644 --- a/io/multiresolutionimageinterface/VSIImage.cpp +++ b/io/multiresolutionimageinterface/VSIImage.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "core/filetools.h" #include "core/Box.h" @@ -300,7 +301,7 @@ void* VSIImage::readDataFromImage(const long long& startX, const long long& star for (int trow=0; trow