Commit 832794f5 authored by Peter Eastman's avatar Peter Eastman
Browse files

Tony's changes to fix errors on Windows

parent 94ecc958
...@@ -159,9 +159,9 @@ static HMODULE loadOneLibrary(const string& file) { ...@@ -159,9 +159,9 @@ static HMODULE loadOneLibrary(const string& file) {
HMODULE handle = LoadLibrary(file.c_str()); HMODULE handle = LoadLibrary(file.c_str());
SetErrorMode(oldErrorMode); // Restore previous error mode. SetErrorMode(oldErrorMode); // Restore previous error mode.
if (handle == NULL) { if (handle == NULL) {
string message; stringstream message;
stringstream(message) << "Error loading library " << file << ": " << GetLastError(); message << "Error loading library " << file << ": " << GetLastError();
throw OpenMMException(message); throw OpenMMException(message.str());
} }
return handle; return handle;
} }
......
...@@ -5,9 +5,14 @@ CONFIGURE_FILE(${CL_SOURCE_DIR}/${CL_SOURCE_CLASS}.cpp.in ${CL_KERNELS_CPP}) ...@@ -5,9 +5,14 @@ CONFIGURE_FILE(${CL_SOURCE_DIR}/${CL_SOURCE_CLASS}.cpp.in ${CL_KERNELS_CPP})
FOREACH(file ${OPENCL_KERNELS}) FOREACH(file ${OPENCL_KERNELS})
# Load the file contents and process it. # Load the file contents and process it.
FILE(STRINGS ${file} file_content NEWLINE_CONSUME) FILE(STRINGS ${file} file_content NEWLINE_CONSUME)
STRING(REPLACE \\\n \\\\\n file_content "${file_content}") # Replace all backslashes by double backslashes as they are being put in a C string.
STRING(REPLACE \" \\\" file_content "${file_content}") # Be careful not to replace the backslash before a semicolon as that is the CMAKE
STRING(REPLACE \n \\n\"\n\" file_content "${file_content}") # internal escaping of a semicolon to prevent it from acting as a list seperator.
STRING(REGEX REPLACE "\\\\([^;])" "\\\\\\\\\\1" file_content "${file_content}")
# Escape double quotes as being put in a C string.
STRING(REPLACE "\"" "\\\"" file_content "${file_content}")
# Split in separate C strings for each line.
STRING(REPLACE "\n" "\\n\"\n\"" file_content "${file_content}")
# Determine a name for the variable that will contain this file's contents # Determine a name for the variable that will contain this file's contents
FILE(RELATIVE_PATH filename ${CL_SOURCE_DIR}/kernels ${file}) FILE(RELATIVE_PATH filename ${CL_SOURCE_DIR}/kernels ${file})
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
#include "openmm/internal/windowsExport.h"
#include <string> #include <string>
namespace OpenMM { namespace OpenMM {
...@@ -37,7 +38,7 @@ namespace OpenMM { ...@@ -37,7 +38,7 @@ namespace OpenMM {
* kernels subfolder. * kernels subfolder.
*/ */
class OpenCLKernelSources { class OPENMM_EXPORT OpenCLKernelSources {
public: public:
@CL_FILE_DECLARATIONS@ @CL_FILE_DECLARATIONS@
}; };
......
...@@ -75,7 +75,7 @@ namespace OpenMM { ...@@ -75,7 +75,7 @@ namespace OpenMM {
*/ */
template <class TRAIT> template <class TRAIT>
class OPENMM_EXPORT OpenCLSort { class OpenCLSort {
public: public:
/** /**
* Create an OpenCLSort object for sorting data of a particular type. * Create an OpenCLSort object for sorting data of a particular type.
......
...@@ -344,7 +344,7 @@ void ReferenceCCMAAlgorithm::setTolerance( RealOpenMM tolerance ){ ...@@ -344,7 +344,7 @@ void ReferenceCCMAAlgorithm::setTolerance( RealOpenMM tolerance ){
int ReferenceCCMAAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoordinates, int ReferenceCCMAAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoordinates,
vector<RealVec>& atomCoordinatesP, vector<RealVec>& atomCoordinatesP,
vector<RealOpenMM>& inverseMasses ){ vector<RealOpenMM>& inverseMasses ){
applyConstraints(numberOfAtoms, atomCoordinates, atomCoordinatesP, inverseMasses, false); return applyConstraints(numberOfAtoms, atomCoordinates, atomCoordinatesP, inverseMasses, false);
} }
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -363,7 +363,7 @@ int ReferenceCCMAAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoord ...@@ -363,7 +363,7 @@ int ReferenceCCMAAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoord
int ReferenceCCMAAlgorithm::applyToVelocities(int numberOfAtoms, std::vector<OpenMM::RealVec>& atomCoordinates, int ReferenceCCMAAlgorithm::applyToVelocities(int numberOfAtoms, std::vector<OpenMM::RealVec>& atomCoordinates,
std::vector<OpenMM::RealVec>& velocities, std::vector<RealOpenMM>& inverseMasses) { std::vector<OpenMM::RealVec>& velocities, std::vector<RealOpenMM>& inverseMasses) {
applyConstraints(numberOfAtoms, atomCoordinates, velocities, inverseMasses, true); return applyConstraints(numberOfAtoms, atomCoordinates, velocities, inverseMasses, true);
} }
int ReferenceCCMAAlgorithm::applyConstraints(int numberOfAtoms, vector<RealVec>& atomCoordinates, int ReferenceCCMAAlgorithm::applyConstraints(int numberOfAtoms, vector<RealVec>& atomCoordinates,
......
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