[CMake] Compiling OpenGL application with CMake

Philip Lowman philip at yhbt.com
Thu Feb 19 21:30:25 EST 2009

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

> Thanks Philip,
> that worked flawlessly!
> I would say that *this* is the most compact CMake specification to compile
> a Glut/OpenGL application then:
> *find_package(GLUT)
> find_package(OpenGL)
> ADD_EXECUTABLE(mesh_view mesh_view.cpp)

Yes, that's pretty much all you should need to get started.

You might want to consider adding the REQUIRED keyword to the find_package()
command if the package is absolutely essential to compiling your entire
project.  It should yield a far more useful error message if the package is
not found.

If you don't declare a package REQUIRED, a good rule of thumb is to use
conditionals keyed on the CMake module's found variable (e.g OPENGL_FOUND )
to control where you use it.

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

More information about the CMake mailing list