final version

This commit is contained in:
zanostro 2025-12-07 11:16:00 +01:00
parent 098766bb65
commit 042bae9089
8 changed files with 143 additions and 21 deletions

View file

@ -1,8 +1,9 @@
# Simple Makefile wrapper to configure, build and run the CMake project.
# Usage:
# make # builds (default)
# make build # configure + build
# make run # build (if needed) and run the executable
# make # configure + build with all cores
# make build # configure + build with all cores
# make all # clean + configure + build + run
# make run # just run the executable (no build)
# make clean # run CMake clean (or remove build files)
# make distclean # remove build dir and generated targets
@ -11,27 +12,33 @@ BUILD_DIR := build
CMAKE_BUILD_TYPE ?= Release
TARGET := target/bin/simulator_exec
GUI_TARGET := target/bin/simulator_qt
NPROC := $(shell nproc)
.PHONY: all configure build run clean distclean
all: build
# Default target: just build
default: build
# make all: clean, build, then run
all: clean build run
configure:
@echo "Configuring (build dir: $(BUILD_DIR), type: $(CMAKE_BUILD_TYPE))"
$(CMAKE) -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
build: configure
@echo "Building..."
$(CMAKE) --build $(BUILD_DIR) -j$(shell nproc)
@echo "Building with $(NPROC) cores..."
$(CMAKE) --build $(BUILD_DIR) -j$(NPROC)
run: build
# make run: just launch the executable (no build)
run:
@echo "Running primary target..."
# Prefer GUI if avail able, otherwise fall back to console executable
# Prefer GUI if available, otherwise fall back to console executable
@if [ -x "$(GUI_TARGET)" ]; then \
echo "Launching GUI: $(GUI_TARGET)"; \
sh -c 'nohup env QT_QPA_PLATFORM=xcb ./$(GUI_TARGET) >/dev/null 2>&1 & echo $! > "$(BUILD_DIR)/simulator_qt.pid"'; \
./$(GUI_TARGET); \
elif [ -x "$(TARGET)" ]; then \
@./$(TARGET); \
./$(TARGET); \
else \
echo "No runnable target found (tried $(GUI_TARGET) and $(TARGET))."; exit 1; \
fi
@ -53,7 +60,9 @@ build-gui: configure
clean:
@echo "Cleaning build (CMake clean)..."
-$(CMAKE) --build $(BUILD_DIR) --target clean || true
@echo "Removing target directory..."
-rm -rf target/
distclean:
@echo "Removing build artifacts and generated files..."
-rm -rf $(BUILD_DIR) CMakeFiles CMakeCache.txt cmake_install.cmake target/bin/*
-rm -rf $(BUILD_DIR) CMakeFiles CMakeCache.txt cmake_install.cmake target/