Step 3 Create CMakeLists.txt
Create CMakeLists.txt
cmake_minimum_required(VERSION 3.26.0)
project(proj01 VERSION 1.0.0)
cmake_policy(SET CMP0072 NEW)
# place for finding Findglfw3.cmake
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# external opengl related libraries
find_package(OpenGL REQUIRED)
find_package(glfw3 REQUIRED)
# adding source files to our exectuable programs
# Note: it is not a good practice to put glad.c in the src folder
# Ideally, it should be put under external/ and used as an external library
# to avoid unnecessary compiling
add_executable(run01 src/main.cpp src/glad.c)
# specify include directories
target_include_directories(run01 PRIVATE include)
# specify library directories
target_link_libraries(run01 ${GLFW3_LIBRARY} OpenGL::GL)Install CMakeTools extension in VSCode

Revise cmake/Findglfw3.cmake if you have a different external or include folder
Test if CMake is working
Last updated