Good evening friends! Such a problem. I want to link the GLEW and GLUT libraries to a project using cmake, but I don’t understand how to do this, because I’ve just started to deal with this build system.

OS: Linux

Tell me please. Paths to libraries:

 GLEW: lib: /usr/lib64/ include: /usr/include/GL/ GLUT: lib: /usr/local/lib/ include: /usr/local/include/GL/ 

    1 answer 1

    It should be something like this:

     find_package(GLEW REQUIRED) find_package(GLUT REQUIRED) include_directories( ${GLEW_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ) target_link_libraries( project_name ${GLEW_LIBRARIES} ${GLUT_LIBRARY} ) 

    Link to small lessons, in the content of which you will find the information you are interested in - link , link

    find_package - look for the CMake extension; used with REQUIRED - this means that in case of unsuccessful search assembly will be interrupted.

    target_link_libraries - we list the instructions that need to be added to the assembly file to connect to the project of third-party libraries.

    Something went wrong ? You go to cmake.org, you are looking for the necessary extensions, see which macros are defined there for a specific extension, if something has changed - change, try .. - does not work? - come back - we understand.