Skip to content

Commit

Permalink
Fix os x compatible problems
Browse files Browse the repository at this point in the history
This fixes some compilation errors and other issues when
using chemkit on Mac OS X.
  • Loading branch information
soplwang authored and kylelutz committed Feb 10, 2012
1 parent 2e51dab commit 397aea9
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ build/

# qt generated files
CMakeLists.txt.user

# os x
.DS_Store
5 changes: 3 additions & 2 deletions src/chemkit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# set a variable for the operating system
if(UNIX)
set(CHEMKIT_OS_UNIX TRUE)
if(APPLE)
set(CHEMKIT_OS_MAC TRUE)
endif()
elseif(WIN32)
set(CHEMKIT_OS_WIN32 TRUE)
elseif(APPLE)
set(CHEMKIT_OS_MAC TRUE)
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
Expand Down
6 changes: 4 additions & 2 deletions src/chemkit/dynamiclibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,13 @@ std::string DynamicLibrary::errorString() const
bool DynamicLibrary::isLibrary(const std::string &fileName)
{
#if defined(CHEMKIT_OS_UNIX)
#if defined(CHEMKIT_OS_MAC)
return boost::algorithm::ends_with(fileName, ".dylib");
#else
return boost::algorithm::ends_with(fileName, ".so");

#endif
#elif defined(CHEMKIT_OS_WIN32)
return boost::algorithm::ends_with(fileName, ".dll");

#else
return false;
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/chemkit/moleculeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
#include <stack>
#include <cassert>

#include <chemkit/atom.h>
#include <chemkit/bond.h>
#include <chemkit/foreach.h>
#include "atom.h"
#include "bond.h"
#include "foreach.h"

namespace chemkit {

Expand Down
6 changes: 6 additions & 0 deletions src/graphics/graphicspainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
#include <chemkit/constants.h>
#include <chemkit/quaternion.h>

#if defined(Q_WS_MAC)
#include <OpenGL/glu.h>
#else
#include <GL/glu.h>
#endif

namespace {

void nurbsErrorCallback(GLenum errorCode)
Expand Down
16 changes: 12 additions & 4 deletions src/graphics/graphicsvertexbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@

#include <QtOpenGL>

#ifdef Q_OS_WIN32
#include "../3rdparty/khronos/GL/glext.h"
#else
#include <GL/glext.h>
#if !defined(Q_WS_MAC)
#if defined(Q_WS_WIN)
#include "../3rdparty/khronos/GL/glext.h"
#else
#include <GL/glext.h>
#endif
#endif

#if !defined(Q_WS_MAC)
namespace {

PFNGLGENBUFFERSPROC glGenBuffers = 0;
Expand Down Expand Up @@ -114,6 +117,7 @@ void setupGlFunctions()
}

} // end anonymous namespace
#endif // !Q_WS_MAC

namespace chemkit {

Expand Down Expand Up @@ -146,7 +150,9 @@ GraphicsVertexBuffer::GraphicsVertexBuffer()
{
d->readyToDraw = false;

#if !defined(Q_WS_MAC)
setupGlFunctions();
#endif

glGenBuffers(1, &d->vertexBuffer);
}
Expand All @@ -158,7 +164,9 @@ GraphicsVertexBuffer::GraphicsVertexBuffer(const QVector<Point3f> &verticies)
d->readyToDraw = false;
d->verticies = verticies;

#if !defined(Q_WS_MAC)
setupGlFunctions();
#endif
glGenBuffers(1, &d->vertexBuffer);
}

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ add_subdirectory(wienerindex)

# only compile xtc plugin on *nix where we have XDR
if(${UNIX})
if(!${APPLE})
add_subdirectory(xtc)
endif()
endif()

add_subdirectory(xyz)
1 change: 1 addition & 0 deletions src/plugins/xtc/xtcfileformat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <boost/make_shared.hpp>

#include <rpc/xdr.h>
#include <rpc/types.h>
#include <chemkit/vector3.h>
#include <chemkit/unitcell.h>
#include <chemkit/trajectory.h>
Expand Down

0 comments on commit 397aea9

Please sign in to comment.