feat: C++ CMake template
This commit is contained in:
Vendored
+49
@@ -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}"
|
||||
)
|
||||
Reference in New Issue
Block a user