From 00d10e4f0ec369df85f4b5ecdc3cbed8aebc9e29 Mon Sep 17 00:00:00 2001 From: sebastian Date: Fri, 17 Apr 2026 11:48:34 +0200 Subject: [PATCH] FIX: Exclude GLFW from test builds --- .gitea/workflows/tests.yml | 2 +- CMakeLists.txt | 71 ++++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/.gitea/workflows/tests.yml b/.gitea/workflows/tests.yml index 8facfde..da8c89c 100644 --- a/.gitea/workflows/tests.yml +++ b/.gitea/workflows/tests.yml @@ -32,7 +32,7 @@ jobs: run: git submodule update --init --recursive - name: Konfigurieren - run: cmake -B build + run: cmake -B build -DBUILD_GAME=OFF - name: Nur Test-Target bauen run: cmake --build build --target LayoutEngineTests diff --git a/CMakeLists.txt b/CMakeLists.txt index f055304..a2cfd79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,23 +1,28 @@ -cmake_minimum_required(VERSION 3.31) +cmake_minimum_required(VERSION 3.20) project(Dicewars_Siedler) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(OpenGL REQUIRED) +option(BUILD_GAME "Build the game executable" ON) -add_subdirectory(lib/glfw) +# GLFW/OpenGL/Freetype nur laden wenn das Spiel gebaut wird +if(BUILD_GAME) + find_package(OpenGL REQUIRED) + add_subdirectory(lib/glfw) -add_library(glad STATIC - lib/glad/src/glad.c -) -target_include_directories(glad PUBLIC - lib/glad/include -) + add_library(glad STATIC + lib/glad/src/glad.c + ) + target_include_directories(glad PUBLIC + lib/glad/include + ) -find_package(Freetype REQUIRED) -include_directories(${FREETYPE_INCLUDE_DIRS}) + find_package(Freetype REQUIRED) + include_directories(${FREETYPE_INCLUDE_DIRS}) +endif() +# Catch2 und Tests immer verfügbar include(FetchContent) FetchContent_Declare( Catch2 @@ -29,19 +34,18 @@ FetchContent_MakeAvailable(Catch2) add_executable(LayoutEngineTests tests/layout/LayoutEngineTest.cpp ) - target_include_directories(LayoutEngineTests PRIVATE src lib/glm ) - target_link_libraries(LayoutEngineTests PRIVATE Catch2::Catch2WithMain) include(CTest) include(Catch) catch_discover_tests(LayoutEngineTests) -add_executable(Dicewars_Siedler src/main.cpp +if(BUILD_GAME) + add_executable(Dicewars_Siedler src/main.cpp src/engine/core/Window.cpp src/engine/core/Window.h src/engine/platform/glfw/GLFWWindow.cpp @@ -285,28 +289,29 @@ add_executable(Dicewars_Siedler src/main.cpp src/game/GameWorldSystems.cpp src/game/GameWorldSystems.h src/engine/core/gui/uiComponent/layout/LayoutEngine.h -) - -target_compile_options(Dicewars_Siedler PRIVATE - -Wall - -Wextra - -Wpedantic - -Werror=return-type -) + ) + target_compile_options(Dicewars_Siedler PRIVATE + -Wall + -Wextra + -Wpedantic + -Werror=return-type + ) -target_include_directories(Dicewars_Siedler PRIVATE - lib/glfw/include - lib/glm - lib/stb_image - lib/tinyobjloader - lib/nlohmann -) + target_include_directories(Dicewars_Siedler PRIVATE + lib/glfw/include + lib/glm + lib/stb_image + lib/tinyobjloader + lib/nlohmann + ) -target_link_libraries(Dicewars_Siedler - PRIVATE + target_link_libraries(Dicewars_Siedler + PRIVATE glfw glad OpenGL::GL - ${FREETYPE_LIBRARIES} -) \ No newline at end of file + ${FREETYPE_LIBRARIES} + ) +endif() +