Files
cuber/deps/Findglad.cmake
T
portersky 47d01f57c0 feat: add RAII window class with OpenGL 4.1 context
- Add cbt::window class in cbt/ directory with RAII lifecycle
- Add setup_opengl and info_opengl for glad init and GL info
- Add Q key to quit the application
- Update CMakeLists.txt with glfw3 and glad dependencies
- Update AGENTS.md with snake_case naming and shell conventions
2026-05-05 21:50:50 +02:00

69 lines
2.1 KiB
CMake

# ==============================================================================
# Find glad
# ==============================================================================
# This module fetches the glad OpenGL loader library.
#
# Targets provided:
# glad::glad - The glad library target
#
# Variables set:
# glad_FOUND - TRUE if glad is available
# glad_LIBRARIES - The glad library target (glad::glad)
# glad_INCLUDE_DIR - Include directories for glad
# glad_VERSION - Version of glad (commit hash or tag)
# ==============================================================================
if (DEFINED _FINDGLAD_INCLUDED)
return()
endif()
set(_FINDGLAD_INCLUDED TRUE)
# Use the version passed to find_package(), or default to commit hash
if (DEFINED glad_FIND_VERSION AND NOT glad_FIND_VERSION STREQUAL "")
set(GLAD_VERSION "${glad_FIND_VERSION}")
else()
set(GLAD_VERSION "f4759d7c5143c0a23391ab05caaf43052cefdd65")
endif()
message(STATUS "Fetching glad ${GLAD_VERSION}")
include(FetchContent)
find_program(GIT_EXECUTABLE git)
if (GIT_EXECUTABLE)
set(GLAD_FETCH_METHOD "GIT")
else()
message(FATAL_ERROR "Fetch with zip not supported.")
endif()
if (GLAD_FETCH_METHOD STREQUAL "GIT")
FetchContent_Declare(
glad
GIT_REPOSITORY https://github.com/mononerv/glad.git
GIT_TAG ${GLAD_VERSION}
)
endif()
FetchContent_MakeAvailable(glad)
if (NOT TARGET glad::glad)
if (TARGET glad)
add_library(glad::glad ALIAS glad)
else()
message(FATAL_ERROR "Could not fetch glad; no target glad or glad::glad available")
endif()
endif()
set(glad_FOUND TRUE)
set(glad_LIBRARIES glad::glad)
set(glad_VERSION "${GLAD_VERSION}")
get_target_property(_glad_inc glad::glad INTERFACE_INCLUDE_DIRECTORIES)
set(glad_INCLUDE_DIR "${_glad_inc}")
# Mark glad includes as SYSTEM to suppress warnings from its headers
if (_glad_inc AND TARGET glad)
set_target_properties(glad PROPERTIES
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_glad_inc}"
)
endif()