[CMake] Compiling OpenGL application with CMake

Philip Lowman philip at yhbt.com
Thu Feb 19 20:30:18 EST 2009

On Thu, Feb 19, 2009 at 8:18 PM, Andrea Tagliasacchi <ata2 at cs.sfu.ca> wrote:

> Hello everybody,
> I have given up on Makefiles, implicit rules and unreadability just annoyed
> me.
> Also the ability of generating cross platform compile files is very
> appealing.
> As far as I compile my independent code (no external libraries)
> everything goes fine. However, one of my applications is a simple
> OpenGL based visualizer and I am having problems finding the correct
> set of setting of the CMakeLists.txt.
> Right now I hacked a *temporary solution* that compiles that file
> in an architecture dependent way:
> find_package(GLUT)
> find_package(OpenGL)
>     SET(CMAKE_CXX_LINK_FLAGS "-framework OpenGL -framework GLUT")
>     ADD_EXECUTABLE(mesh_view mesh_view.cpp)
> Browsing around I was able to construct the following but I am still
> getting
> linking errors as reported below:
> find_package(GLUT)
> find_package(OpenGL)
>    MESSAGE("OpenGL Correctly Found")
>    include_directories(${OPENGL_INCLUDE_DIR})
>    MESSAGE("OpenGL environment missing")
> endif (OPENGL_FOUND)
> Example of linking errors:
> Linking CXX executable mesh_view
> Undefined symbols:
>   "_glViewport", referenced from:
>       reshapeCallback(int, int)in mesh_view.cpp.o
>   "_glMaterialfv", referenced from:
>       displayCallback()     in mesh_view.cpp.o
>   "_glLoadIdentity", referenced from:
>       init_opengl()     in mesh_view.cpp.o
>       motionCallback(int, int)in mesh_view.cpp.o
>       displayCallback()     in mesh_view.cpp.o
> I also checked the CMake files of OpenSceneGraph
> but I can find only include directory specifications, no linking.
> Browsing around I also found the following but even if I add them nothing
> changes:
> INCLUDE(${CMAKE_ROOT}/Modules/FindOpenGL.cmake)

> Any suggestion?


If it fails to link you can use "make VERBOSE=1" to look at the
compiler/linker flags.

Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090219/6ec560d2/attachment.htm>

More information about the CMake mailing list