[CMake] CMAKE 2.8.9, OS X 10.8 and OpenGL

Jason T. Slack-Moehrle slackmoehrle at gmail.com
Wed Aug 15 18:09:49 EDT 2012


Benjamin,


> for me, the following file works
>
> --- BEGIN CMakeLists.txt
> cmake_minimum_required (VERSION 2.8.9)
>
> project(Test)
>
> SET(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
>
> find_package(OpenGL REQUIRED)
> include_directories(${OPENGL_INCLUDE_DIR})
>
> find_package(GLUT REQUIRED)
> include_directories(${GLUT_INCLUDE_DIR})
>
> add_executable(Test main.cpp)
>
> target_link_libraries(Test ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
> --- END CMakeLists.txt

I got it. I was also switching the 'add_executable' and
'target_link_libraries' statements which is why I was getting a
targetnot yet created error too.

> when changing the includes to
>
> #include <cstdlib>
>
> #include <GL/glut.h>
> #include <GL/glext.h>
> #include <GL/gl.h>
> #include <GL/glu.h>

These produce compiler errors for me.

> On OS X, these might be correct the way you specified them.
>> #include <GLUT/glut.h>
>> #include <OpenGL/glext.h>
>> #include <OpenGL/gl.h>
>> #include <OpenGL/glu.h>

These dont, it compiles and I see a window, just nothing works inside
which is my problem to solve :-)
Not related to CMAKE.

Thanks for the help. I will continue with the tutorials as well before
asking questions. I see a lot of ways people use CMAKE for the same
tasks...

-Jason


More information about the CMake mailing list