Commit 98111cdd authored by Christopher Bruns's avatar Christopher Bruns
Browse files

Avoid link error with TestNormalModeLangevin by linking to ${SHARED_TARGET} instead of to "OpenMM"

parent 40f67e33
add_executable(TestNormalModeLangevin TestNormalModeLangevin.cpp) add_executable(TestNormalModeLangevinEXE TestNormalModeLangevin.cpp)
target_link_libraries(TestNormalModeLangevin OpenMM) target_link_libraries(TestNormalModeLangevinEXE ${SHARED_TARGET})
add_test(TestNormalModeLangevin ${EXECUTABLE_OUTPUT_PATH}/TestNormalModeLangevin)
set_tests_properties(TestNormalModeLangevin PROPERTIES ENVIRONMENT add_test(TestNormalModeLangevin TestNormalModeLangevinEXE)
"OPENMM_PLUGIN_DIR=\"${LIBRARY_OUTPUT_DIRECTORY}\""
)
...@@ -2,23 +2,43 @@ ...@@ -2,23 +2,43 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <cstdlib>
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
void mysetenv(const char* name, const char* value) {
#ifdef _MSC_VER
char buffer[1000];
sprintf(buffer, "%s=%s", name, value);
putenv(buffer);
#else
setenv(name, value, 1);
#endif
}
void testLoadNMLPlugin() void testLoadNMLPlugin()
{ {
Platform::loadPluginsFromDirectory(Platform::getDefaultPluginsDirectory()); string pluginDir = Platform::getDefaultPluginsDirectory();
cout << "Default plugins directory = " << pluginDir << endl;
Platform::loadPluginsFromDirectory(pluginDir);
vector<string> kernelName; vector<string> kernelName;
kernelName.push_back("IntegrateNMLStepKernel"); kernelName.push_back("IntegrateNMLStepKernel");
// Was NormalModeLangevin plugin loaded? // Was NormalModeLangevin plugin loaded?
Platform& platform = Platform::findPlatform(kernelName); // throws if no platform with kernel Platform& platform = Platform::findPlatform(kernelName); // throws if no platform with kernel
} }
int main() int main(int argc, const char* argv[])
{ {
try try
{ {
if (argc > 1) {
const char* plugin_dir = argv[1];
// 0 => don't set if variable exists
mysetenv("OPENMM_PLUGIN_DIR", plugin_dir);
cout << plugin_dir << endl;
cout << getenv("OPENMM_PLUGIN_DIR") << endl;
}
testLoadNMLPlugin(); testLoadNMLPlugin();
cout << "tests passed" << endl; cout << "tests passed" << endl;
return 0; return 0;
......
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