diff options
| author | Jesper Jensen <jesper@jnsn.dev> | 2026-06-05 13:53:11 +0200 |
|---|---|---|
| committer | Jesper Jensen <jesper@jnsn.dev> | 2026-06-05 13:53:11 +0200 |
| commit | 1af2dfbde432af9f13e8fba09b7ca29f5de71863 (patch) | |
| tree | 578304e26a1d34a3ed0adbb6ce854c761a203d6a /Makefile | |
| parent | 7bf056e5c652254c3a43e748b17cdbb7361a6a3c (diff) | |
Add imgui compilation
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 27 |
1 files changed, 22 insertions, 5 deletions
@@ -1,4 +1,5 @@ CC ?= gcc +CC ?= g++ SRCDIR ?= src INCDIR ?= inc @@ -6,11 +7,13 @@ OBJDIR ?= obj TSTDIR ?= test EXMDIR ?= examples -LIBS = -lm -INCS = -Ithirdparty/cglm/include -Iinc/ +PKGS = sdl2 opengl +LIBS = -lm $(shell pkg-config --libs $(PKGS)) +INCS = -Ithirdparty/cglm/include -Ithirdparty/ -Iinc/ CFLAGS ?= -D_FORTIFY_SOURCE=2 -Wall -Werror -Wno-error=unused-variable -g -Og -CFLAGS += -std=gnu23 -fms-extensions -flto +CFLAGS += -std=gnu23 -fms-extensions -flto $(shell pkg-config --cflags $(PKGS)) -DCIMGUI_USE_OPENGL3 -DCIMGUI_USE_SDL2 +CXXFLAGS += -flto $(shell pkg-config --cflags $(PKGS)) -DCIMGUI_USE_OPENGL3 -DCIMGUI_USE_SDL2 -DIMGUI_IMPL_API='extern "C"' APP_MAIN_SOURCES = $(SRCDIR)/main.c APP_MAIN_OBJS = $(APP_MAIN_SOURCES:%.c=$(OBJDIR)/%.o) @@ -30,6 +33,8 @@ EXM_OBJS = $(EXM_SOURCES:%.c=$(OBJDIR)/%.o) EXM_DEPS = $(EXM_OBJS:%.o=%.d) EXM_APPS = $(EXM_SOURCES:%.c=$(OBJDIR)/%) +IMGUI_OBJS = $(OBJDIR)/thirdparty/cimgui/imgui/backends/imgui_impl_sdl2.o $(OBJDIR)/thirdparty/cimgui/imgui/backends/imgui_impl_opengl3.o + -include $(APP_DEPS) $(APP_MAIN_DEPS) $(TST_DEPS) $(EXM_DEPS) # We don't really need to run the tests for bear to record them @@ -37,8 +42,14 @@ compile_commands.json: clean Makefile $(APP_SOURCES) @rm -f "$@" bear -- make main -main: $(APP_MAIN_OBJS) $(APP_OBJS) - $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(APP_MAIN_OBJS) $(APP_OBJS) $(LIBS) +.PHONY: thirdparty/cimgui/cimgui.so +thirdparty/cimgui/cimgui.so: + make -C thirdparty/cimgui + +LIBS += -Lthirdparty/cimgui -Wl,-rpath,'$$ORIGIN/thirdparty/cimgui' -lcimgui -lstdc++ + +main: $(APP_MAIN_OBJS) $(APP_OBJS) thirdparty/cimgui/cimgui.so $(IMGUI_OBJS) + $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(APP_MAIN_OBJS) $(APP_OBJS) $(IMGUI_OBJS) $(LIBS) $(OBJDIR)/%.o: %.c @mkdir -p $(dir $@) @@ -55,6 +66,7 @@ $(OBJDIR)/examples/%: $(OBJDIR)/examples/%.o $(APP_OBJS) clean: @rm -rf $(OBJDIR) @rm -f main + @make -C thirdparty/cimgui clean test: $(TST_APPS) @echo "Running tests" @@ -64,3 +76,8 @@ examples: $(EXM_APPS) .DEFAULT_GOAL := all all: main test examples + +# Imgui specific compile rules +$(OBJDIR)/%.o: %.cpp + @mkdir -p $(dir $@) + $(CXX) $(CXXFLAGS) $(INCS) -Ithirdparty/cimgui/imgui/ -MMD -o $@ -c $< |
