Commit 7254af58 authored by Peter Eastman's avatar Peter Eastman
Browse files

Added Platform::getDefaultPluginDirectory(). Plugins are now installed into...

Added Platform::getDefaultPluginDirectory().  Plugins are now installed into .../openmm/lib/plugins.
parent ddceaa1b
...@@ -191,6 +191,14 @@ public: ...@@ -191,6 +191,14 @@ public:
* @return the names of all files which were successfully loaded as libraries * @return the names of all files which were successfully loaded as libraries
*/ */
static std::vector<std::string> loadPluginsFromDirectory(std::string directory); static std::vector<std::string> loadPluginsFromDirectory(std::string directory);
/**
* Get the default directory from which to load plugins. If the environment variable
* OPENMM_PLUGIN_DIR is set, this returns its value. Otherwise, it returns a platform
* specific default location.
*
* @return the path to the default plugin directory
*/
static std::string getDefaultPluginDirectory();
private: private:
// Retarded visual studio compiler complains about being unable to // Retarded visual studio compiler complains about being unable to
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#else #else
#include <dlfcn.h> #include <dlfcn.h>
#include <dirent.h> #include <dirent.h>
#include <cstdlib>
#endif #endif
#include <set> #include <set>
...@@ -192,3 +193,18 @@ vector<string> Platform::loadPluginsFromDirectory(string directory) { ...@@ -192,3 +193,18 @@ vector<string> Platform::loadPluginsFromDirectory(string directory) {
} }
return loadedLibraries; return loadedLibraries;
} }
string Platform::getDefaultPluginDirectory() {
char* dir = getenv("OPENMM_PLUGIN_DIR");
#ifdef _MSC_VER
if (dir == NULL)
dir = getenv("PROGRAMFILES");
if (dir == NULL)
return "C:\\\\Program Files\\OpenMM\\lib\\plugins";
return string(dir)+"\\OpenMM\\lib\\plugins";
#else
if (dir == NULL)
return "/usr/local/openmm/lib/plugins";
return string(dir);
#endif
}
...@@ -212,8 +212,8 @@ ENDIF(INCLUDE_BROOK_STATIC) ...@@ -212,8 +212,8 @@ ENDIF(INCLUDE_BROOK_STATIC)
#install #install
IF(INCLUDE_BROOK_STATIC) IF(INCLUDE_BROOK_STATIC)
INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${STATIC_BROOK_TARGET}) INSTALL_TARGETS(/lib/plugins RUNTIME_DIRECTORY /lib/plugins ${STATIC_BROOK_TARGET})
ENDIF(INCLUDE_BROOK_STATIC) ENDIF(INCLUDE_BROOK_STATIC)
INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${SHARED_BROOK_TARGET}) INSTALL_TARGETS(/lib/plugins RUNTIME_DIRECTORY /lib/plugins ${SHARED_BROOK_TARGET})
...@@ -19,4 +19,4 @@ CUDA_ADD_LIBRARY(${SHARED_TARGET} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ...@@ -19,4 +19,4 @@ CUDA_ADD_LIBRARY(${SHARED_TARGET} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES}
TARGET_LINK_LIBRARIES(${SHARED_TARGET} debug ${OPENMM_LIBRARY_NAME}_d optimized ${OPENMM_LIBRARY_NAME} cudpp cutil) TARGET_LINK_LIBRARIES(${SHARED_TARGET} debug ${OPENMM_LIBRARY_NAME}_d optimized ${OPENMM_LIBRARY_NAME} cudpp cutil)
SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES COMPILE_FLAGS "-DOPENMM_BUILDING_SHARED_LIBRARY") SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES COMPILE_FLAGS "-DOPENMM_BUILDING_SHARED_LIBRARY")
INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${SHARED_TARGET}) INSTALL_TARGETS(/lib/plugins RUNTIME_DIRECTORY /lib/plugins ${SHARED_TARGET})
...@@ -24,4 +24,4 @@ SET_TARGET_PROPERTIES(${STATIC_TARGET} PROPERTIES COMPILE_FLAGS ${CUDA_STATIC_CO ...@@ -24,4 +24,4 @@ SET_TARGET_PROPERTIES(${STATIC_TARGET} PROPERTIES COMPILE_FLAGS ${CUDA_STATIC_CO
TARGET_LINK_LIBRARIES(${STATIC_TARGET} debug ${OPENMM_LIBRARY_NAME}_static_d optimized ${OPENMM_LIBRARY_NAME}_static cudpp cutil) TARGET_LINK_LIBRARIES(${STATIC_TARGET} debug ${OPENMM_LIBRARY_NAME}_static_d optimized ${OPENMM_LIBRARY_NAME}_static cudpp cutil)
INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${STATIC_TARGET}) INSTALL_TARGETS(/lib/plugins RUNTIME_DIRECTORY /lib/plugins ${STATIC_TARGET})
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