[Examples/tigr-demo] Changed build process to CMake

This commit is contained in:
Noah Breedy 2026-06-25 18:37:15 -04:00
parent 068353bb31
commit 159cf2cb96
3 changed files with 57 additions and 43 deletions

View file

@ -12,6 +12,7 @@ option(CLAY_INCLUDE_SDL3_EXAMPLES "Build SDL 3 examples" OFF)
option(CLAY_INCLUDE_WIN32_GDI_EXAMPLES "Build Win32 GDI examples" OFF)
option(CLAY_INCLUDE_SOKOL_EXAMPLES "Build Sokol examples" OFF)
option(CLAY_INCLUDE_PLAYDATE_EXAMPLES "Build Playdate examples" OFF)
option(CLAY_INCLUDE_TIGR_EXAMPLES "Build Tigr examples" OFF)
message(STATUS "CLAY_INCLUDE_DEMOS: ${CLAY_INCLUDE_DEMOS}")
@ -45,6 +46,10 @@ if(CLAY_INCLUDE_ALL_EXAMPLES OR CLAY_INCLUDE_SOKOL_EXAMPLES)
add_subdirectory("examples/sokol-video-demo")
add_subdirectory("examples/sokol-corner-radius")
endif()
if(CLAY_INCLUDE_ALL_EXAMPLES OR CLAY_INCLUDE_TIGR_EXAMPLES)
add_subdirectory("examples/tigr-demo")
endif()
# Playdate example not included in ALL because users need to install the playdate SDK first which requires a license agreement
if(CLAY_INCLUDE_PLAYDATE_EXAMPLES)

View file

@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.16)
project(demo C)
set(CMAKE_C_STANDARD 99)
# -----------------------------
# EDIT ME WITH RELATIVE PATH TO:
# tigr.c & tigr.h
set(TIGR_DIR "../../../tigr")
add_executable(demo
main.c
${TIGR_DIR}/tigr.c
../../renderers/tigr/tigr_utils.c
../../renderers/tigr/clay_renderer_tigr.c
)
target_include_directories(demo PRIVATE
${TIGR_DIR}
)
# Platform-specific libraries
if(WIN32)
target_link_libraries(demo PRIVATE
opengl32
gdi32
)
elseif(APPLE)
find_library(OPENGL_FRAMEWORK OpenGL)
find_library(COCOA_FRAMEWORK Cocoa)
target_link_libraries(demo PRIVATE
${OPENGL_FRAMEWORK}
${COCOA_FRAMEWORK}
)
elseif(UNIX)
target_link_libraries(demo PRIVATE
m
GLU
GL
X11
)
endif()
add_custom_command(TARGET demo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/resources
$<TARGET_FILE_DIR:demo>/resources
)

View file

@ -1,43 +0,0 @@
CC := gcc
# -----------------------------
# EDIT ME WITH RELATIVE PATH TO:
#
# tigr.c & tigr.h
# -----------------------------
TIGR_DIR := <PATH_TO_TIGR>
OUTFILE := demo
CFLAGS :=
LDFLAGS := -lm
# -----------------------------
# platform flags
# -----------------------------
ifeq ($(OS),Windows_NT)
LDFLAGS += -lopengl32 -lgdi32
RM := del /q
else
OS := $(shell uname -s)
ifeq ($(OS),Darwin)
LDFLAGS += -framework OpenGL -framework Cocoa
else ifeq ($(OS),Linux)
LDFLAGS += -lGLU -lGL -lX11
endif
RM := rm -f
endif
SRCS := \
main.c \
$(TIGR_DIR)/tigr.c \
../../renderers/tigr/tigr_utils.c \
../../renderers/tigr/clay_renderer_tigr.c
all: main.c
$(CC) -I$(TIGR_DIR) $(CFLAGS) $(SRCS) -o $(OUTFILE) $(LDFLAGS)
clean:
$(RM) $(OUTFILE)