From 159cf2cb960875d60e3842fd568cf3096ba8da50 Mon Sep 17 00:00:00 2001 From: Noah Breedy Date: Thu, 25 Jun 2026 18:37:15 -0400 Subject: [PATCH] [Examples/tigr-demo] Changed build process to CMake --- CMakeLists.txt | 5 +++ examples/tigr-demo/CMakeLists.txt | 52 +++++++++++++++++++++++++++++++ examples/tigr-demo/Makefile | 43 ------------------------- 3 files changed, 57 insertions(+), 43 deletions(-) create mode 100644 examples/tigr-demo/CMakeLists.txt delete mode 100644 examples/tigr-demo/Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ab1b94..7a9543e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/examples/tigr-demo/CMakeLists.txt b/examples/tigr-demo/CMakeLists.txt new file mode 100644 index 0000000..f159169 --- /dev/null +++ b/examples/tigr-demo/CMakeLists.txt @@ -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 + $/resources +) diff --git a/examples/tigr-demo/Makefile b/examples/tigr-demo/Makefile deleted file mode 100644 index 781295a..0000000 --- a/examples/tigr-demo/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -CC := gcc - -# ----------------------------- -# EDIT ME WITH RELATIVE PATH TO: -# -# tigr.c & tigr.h -# ----------------------------- -TIGR_DIR := - -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)