cmake_minimum_required(VERSION 3.9) project(OpengGL_Example) set(CMAKE_CXX_STANDARD 17) set(CMAKE_VERBOSE_MAKEFILE ON) add_executable(opengl_example main.cpp) # Set executable dependency libraries # Equivalent to pass flags -lGL, -lGLU and -lglut target_link_libraries(opengl_example GL GLU glut) # Add target to run executable add_custom_target(run-ex1 COMMAND opengl_example DEPENDS opengl_example WORKING_DIRECTORY ${CMAKE_PROJECT_DIR} )