skaslev / gl3w

Simple OpenGL core profile loading
http://github.com/skaslev/gl3w
The Unlicense
705 stars 157 forks source link

Implement INTERFACE library CMakeLists.txt #40

Closed 0x47 closed 7 years ago

0x47 commented 7 years ago

This is a comprehensive CMakeLists.txt for this project which I created for my personal use. I thought you might want it because the current CMakeLists.txt is far from ideal.

The usage is as simple as it is elegant. You can make this as usual which will generate the source files (.h and .c) and create *config.cmake and *targets.cmake files. These will then be automatically used by CMake and allow you to do the following in your project:

find_project(gl3w REQUIRED)
# ...
add_executable(myapp foo.c bar.c)   # or add_library(), whatever
target_link_libraries(myapp gl3w)   # <= this line is important

The last line will automatically include the gl3w headers, it will automatically link "myapp" to OpenGL (as the gl3w CMake pulls this dependency) and it will automatically compile gl3w.c.

Hope you find this useful. Thanks for gl3w!

skaslev commented 7 years ago

Looks great. Thanks.