libglui / glui

GLUI is a GLUT-based C++ user interface library which provides controls such as buttons, checkboxes, radio buttons, and spinners to OpenGL applications. It is window-system independent, using GLUT or FreeGLUT.
Other
196 stars 81 forks source link

Cmake install rules #60

Closed simogasp closed 7 years ago

simogasp commented 7 years ago

Hi @josch

I added the cmake install rules to make it easier to use the library as a third party. Now make install install all the built libs, the headers and the examples in CMAKE_INSTALL_PREFIX (default /usr/local). More importantly, it generates the gluiConfig.cmake (in lib/cmake/glui/) that can be used to import the library in another cmake project. I added a BUILD.md that explains it, it is basically enough to write

# Find the package from the gluiConfig.cmake
# in <prefix>/lib/cmake/glui/. Under the namespace glui::
# it exposes the target glui that allows you to compile
# and link with the library
find_package(glui CONFIG REQUIRED)
...
# suppose you want to try it out in a executable
add_executable(gluitest yourfile.cpp)
# add link to the library, use glui::glui_static if you want to link with the static version
target_link_libraries(gluitest PUBLIC glui::glui)

and then passing the location of gluiConfig.cmake from the cmake command line:

cmake .. -Dglui_DIR=path/to/install/lib/cmake/glui/

Incidentally, I needed to make the minimum required version to 2.8.12 in order to use PUBLIC and PRIVATE in target_link_libraries(), which is very important to propagate correctly the secondary dependencies.

I hope it may help

S.