From f388d6a93858894693c74e9099c867832e6c64a1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 19 Sep 2008 12:49:22 +0000 Subject: [PATCH] From Mathias Froehlich, added support for search in the installed directories for plugins --- CMakeLists.txt | 5 +++++ src/osgDB/FileUtils.cpp | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 496b2cbb7..160b44d96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -532,6 +532,11 @@ ELSE (DYNAMIC_OPENSCENEGRAPH) SET(OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC") ENDIF(DYNAMIC_OPENSCENEGRAPH) +# Add a default plugin search path component +IF (DYNAMIC_OPENSCENEGRAPH) + ADD_DEFINITIONS(-DOSG_DEFAULT_LIBRARY_PATH="${CMAKE_INSTALL_PREFIX}/lib${LIB_POSTFIX}/${OSG_PLUGINS}") +ENDIF(DYNAMIC_OPENSCENEGRAPH) + INCLUDE(OsgMacroUtils) # OSG Core ADD_SUBDIRECTORY(src) diff --git a/src/osgDB/FileUtils.cpp b/src/osgDB/FileUtils.cpp index 526f784cb..af49e703e 100644 --- a/src/osgDB/FileUtils.cpp +++ b/src/osgDB/FileUtils.cpp @@ -364,6 +364,14 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st return ""; } +static void appendInstallationLibraryFilePaths(osgDB::FilePathList& filepath) +{ +#ifdef OSG_DEFAULT_LIBRARY_PATH + // Append the install prefix path to the library search path if configured + filepath.push_back(OSG_DEFAULT_LIBRARY_PATH); +#endif +} + #if defined(WIN32) && !defined(__CYGWIN__) #include #include @@ -450,6 +458,8 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st convertStringPathIntoFilePathList(ptr,filepath); } #endif + + appendInstallationLibraryFilePaths(filepath); } @@ -463,8 +473,9 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st convertStringPathIntoFilePathList(ptr,filepath); } - convertStringPathIntoFilePathList("/usr/bin/:/usr/local/bin/",filepath); + appendInstallationLibraryFilePaths(filepath); + convertStringPathIntoFilePathList("/usr/bin/:/usr/local/bin/",filepath); } #elif defined(WIN32) @@ -554,6 +565,8 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st // when a DLL is found, so I see no point in removing duplicates. convertStringPathIntoFilePathList(ptr, filepath); } + + appendInstallationLibraryFilePaths(filepath); } #elif defined(__APPLE__) @@ -692,6 +705,8 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st convertStringPathIntoFilePathList(ptr, filepath); } + appendInstallationLibraryFilePaths(filepath); + // Since this is currently the only Objective-C code in the // library, we need an autoreleasepool for obj-c memory management. // If more Obj-C is added, we might move this pool to another @@ -762,6 +777,8 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st convertStringPathIntoFilePathList(ptr, filepath); } + appendInstallationLibraryFilePaths(filepath); + const std::string OSG_PLUGIN_PATH("/OpenSceneGraph/PlugIns"); CFURLRef url; CFBundleRef myBundle; @@ -865,6 +882,8 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st { convertStringPathIntoFilePathList(ptr, filepath); } + + appendInstallationLibraryFilePaths(filepath); } #endif @@ -879,6 +898,7 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st convertStringPathIntoFilePathList(ptr,filepath); } + appendInstallationLibraryFilePaths(filepath); #if defined(__ia64__) || defined(__x86_64__) convertStringPathIntoFilePathList("/usr/lib/:/usr/lib64/:/usr/local/lib/:/usr/local/lib64/",filepath);