Missing GL directory CMake on snow leopard

I am trying to port some code to OSx and it is based on cuda and opengl.

The problem I am having is that the glu.h is not located in a GL directory but directly in /System/Library/Frameworks/OpenGL.framework/Headers

bash-3.2$ ls /System/Library/Frameworks/OpenGL.framework/Headers
CGLContext.h OpenGL.h
CGLCurrent.h gl.h
CGLDevice.h glext.h
CGLIOSurface.h gliContext.h
CGLMacro.h gliDispatch.h
CGLProfiler.h glu.h
CGLProfilerFunctionEnum.h gluContext.h
CGLRenderers.h gluMacro.h
CGLTypes.h

Using CMake search function, I can find automatically /System/Library/Frameworks/OpenGL.framework/Headers by using find_package(OpenGL) and ${OPENGL_INLCUDE_DIR}

All this lead to the following problem
/Developer/GPU Computing/C/common/inc/GL/glut.h:59:19: error: GL/gl.h: No such file or directory

It seems that it is a classic problem http://www.blender.org/forum/viewtopic.php…d1b424be80586fc

Any headers on how to fix this ? without modifying glut.h

Cheers,
Koubiak

This is what we do in one of our projects:

#ifdef __APPLE__

#  include <GLUT/glut.h>

#else

#  include <GL/glut.h>

#endif

void display()

{

}

int main(int argc, char* argv[])

{

  glutInit(&argc, argv);

  glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);

  glutCreateWindow("OSX test");

  glutDisplayFunc(display);

  glutMainLoop();

return 0;

}

Then the CMake code looks like this:

cmake_minimum_required(VERSION 2.6)

project(glut-compile)

# As of CMake 2.6 policies were introduced in order to provide a mechanism for

# adding backwards compatibility one feature at a time.  We will just specify

# that all policies will use version 2.6 symantics.

cmake_policy(VERSION 2.6)

find_package(OpenGL REQUIRED)

find_package(GLUT REQUIRED)

# Some systems don't need Xmu for glut.  Remove it if it wasn't found.

if( DEFINED GLUT_Xmu_LIBRARY AND NOT GLUT_Xmu_LIBRARY)

  list(REMOVE_ITEM GLUT_LIBRARIES ${GLUT_Xmu_LIBRARY})

endif()

add_executable(glut-compile glut-compile.cpp)

target_link_libraries(glut-compile ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES})

This is what we do in one of our projects:

#ifdef __APPLE__

#  include <GLUT/glut.h>

#else

#  include <GL/glut.h>

#endif

void display()

{

}

int main(int argc, char* argv[])

{

  glutInit(&argc, argv);

  glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);

  glutCreateWindow("OSX test");

  glutDisplayFunc(display);

  glutMainLoop();

return 0;

}

Then the CMake code looks like this:

cmake_minimum_required(VERSION 2.6)

project(glut-compile)

# As of CMake 2.6 policies were introduced in order to provide a mechanism for

# adding backwards compatibility one feature at a time.  We will just specify

# that all policies will use version 2.6 symantics.

cmake_policy(VERSION 2.6)

find_package(OpenGL REQUIRED)

find_package(GLUT REQUIRED)

# Some systems don't need Xmu for glut.  Remove it if it wasn't found.

if( DEFINED GLUT_Xmu_LIBRARY AND NOT GLUT_Xmu_LIBRARY)

  list(REMOVE_ITEM GLUT_LIBRARIES ${GLUT_Xmu_LIBRARY})

endif()

add_executable(glut-compile glut-compile.cpp)

target_link_libraries(glut-compile ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES})

Thanks I will try this out!

Thanks I will try this out!

Just a quick update.

It worked like a charm!

Thanks a lot and go utes ;)

Just a quick update.

It worked like a charm!

Thanks a lot and go utes ;)