feat: C++ CMake template

This commit is contained in:
2026-10-04 22:48:25 +02:00
parent 425713fb49
commit e487e66f64
38 changed files with 2385 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
# ==============================================================================
# Find stb
# ==============================================================================
# This module fetches the stb single-file public domain libraries
# (stb_image_write.h for PNG writing, etc.).
#
# Targets provided:
# stb::stb - Interface library (add #define STB_IMAGE_WRITE_IMPLEMENTATION
# in exactly one .cpp before including "stb_image_write.h")
#
# Variables set:
# stb_FOUND - TRUE if stb is available
# stb_INCLUDE_DIR - Include directories for stb
# stb_VERSION - Version of stb (commit)
# ==============================================================================
if (DEFINED _FINDSTB_INCLUDED)
return()
endif()
set(_FINDSTB_INCLUDED TRUE)
# Pin to a recent stable commit
set(STB_VERSION "master")
message(STATUS "Fetching stb ${STB_VERSION}")
include(FetchContent)
FetchContent_Declare(
stb
URL https://github.com/nothings/stb/archive/refs/heads/master.zip
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_MakeAvailable(stb)
add_library(stb INTERFACE)
target_include_directories(stb INTERFACE "${stb_SOURCE_DIR}")
add_library(stb::stb ALIAS stb)
set(stb_FOUND TRUE)
set(stb_INCLUDE_DIR "${stb_SOURCE_DIR}")
set(stb_VERSION "${STB_VERSION}")
# Mark as SYSTEM includes
set_target_properties(stb PROPERTIES
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${stb_SOURCE_DIR}"
)