diff --git a/CMakeLists.txt b/CMakeLists.txt index d72f10b71..cc9f81dea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,3 +23,5 @@ set(SCRIPT_API "None" CACHE STRING "Which scripting API/language to use, if any. set_property(CACHE SCRIPT_API PROPERTY STRINGS "None" "C#") set(SCRIPT_BINDING_GENERATION OFF CACHE BOOL "If true, script binding generation will be supported through a specialized build target. Enable this if you plan on modifying the scripting API. Requires the SBGen tool dependency. Only relevant if you have selected a SCRIPT_API other than \"None\".") + +set(DYNLIB_EXTRA_SEARCH_DIRECTORY "" CACHE STRING "If non-empty DynLib loading additionally searches the specified directory for libraries") diff --git a/Source/CMake/BsFrameworkConfig.h.in b/Source/CMake/BsFrameworkConfig.h.in index 15125b036..6410927cb 100644 --- a/Source/CMake/BsFrameworkConfig.h.in +++ b/Source/CMake/BsFrameworkConfig.h.in @@ -18,3 +18,8 @@ #define BS_VERSION_STRING _MKSTR(BS_VERSION_MAJOR) "." _MKSTR(BS_VERSION_MINOR) "." _MKSTR(BS_VERSION_PATCH) ".0" #define BS_IS_BANSHEE3D @BS_IS_BANSHEE3D@ + +#define BS_DYNLIB_EXTRA_ENABLED @BS_DYNLIB_EXTRA_ENABLED@ +#if BS_DYNLIB_EXTRA_ENABLED == 1 +#define BS_DYNLIB_EXTRA_SEARCH_DIRECTORY "@DYNLIB_EXTRA_SEARCH_DIRECTORY@" +#endif diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 6f6ec7770..418f802df 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -116,6 +116,12 @@ else() set(BS_SCRIPTING_ENABLED 0) endif() +if(NOT DYNLIB_EXTRA_SEARCH_DIRECTORY STREQUAL "") + set(BS_DYNLIB_EXTRA_ENABLED 1) +else() + set(BS_DYNLIB_EXTRA_ENABLED 0) +endif() + ## Generate config files configure_file("${BSF_SOURCE_DIR}/CMake/BsEngineConfig.h.in" "${PROJECT_BINARY_DIR}/Generated/bsfEngine/BsEngineConfig.h") configure_file("${BSF_SOURCE_DIR}/CMake/BsFrameworkConfig.h.in" "${PROJECT_BINARY_DIR}/Generated/bsfUtility/BsFrameworkConfig.h") diff --git a/Source/Foundation/bsfUtility/Utility/BsDynLib.cpp b/Source/Foundation/bsfUtility/Utility/BsDynLib.cpp index 55e967bbd..8da292627 100644 --- a/Source/Foundation/bsfUtility/Utility/BsDynLib.cpp +++ b/Source/Foundation/bsfUtility/Utility/BsDynLib.cpp @@ -37,8 +37,15 @@ namespace bs if (!mHandle) { - BS_EXCEPT(InternalErrorException, - "Could not load dynamic library " + mName + ". System Error: " + dynlibError()); +#if BS_DYNLIB_EXTRA_ENABLED == 1 + mHandle = (DYNLIB_HANDLE)DYNLIB_LOAD(Path::combine(Path(BS_DYNLIB_EXTRA_SEARCH_DIRECTORY), + Path(mName)).toString().c_str()); +#endif // BS_DYNLIB_EXTRA_ENABLED + if (!mHandle) + { + BS_EXCEPT(InternalErrorException, + "Could not load dynamic library " + mName + ". System Error: " + dynlibError()); + } } }