Files
deepMiner/CMakeLists.txt
fegger 1680388189 Add SDL2 GUI support and fix World surface logic
- Integrate SDL2 GUI rendering into the Game class
- Update World::getSurfaceLevel to correctly identify surface height
- Improve ASSERT_EQ macro to avoid multiple evaluation of arguments
- Fix typo in main_gui.cpp include
- Update CMakeLists.txt to include Threads package
2026-04-29 02:57:41 +02:00

67 lines
1.5 KiB
CMake

cmake_minimum_required(VERSION 3.15)
project(deep_miner)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Compiler warnings
if(MSVC)
add_compile_options(/W4)
else()
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(Threads REQUIRED)
# All robot + world sources (shared between game and test binaries)
set(LIB_SOURCES
src/BaseRobot.cpp
src/World.cpp
src/SortBot.cpp
src/DigDeepBot.cpp
src/RandomBot.cpp
src/SmartBot.cpp
src/LookaheadBot.cpp
)
option(BUILD_GUI "Build SDL2 GUI target" OFF)
if (BUILD_GUI)
find_package(SDL2 REQUIRED)
find_package(SDL2_ttf REQUIRED)
add_executable(deep_miner_gui
${LIB_SOURCES}
src/Game.cpp
src/Renderer.cpp
main_gui.cpp
)
target_compile_definitions(deep_miner_gui PRIVATE WITH_SDL2_GUI)
target_include_directories(deep_miner_gui PRIVATE include ${SDL2_INCLUDE_DIRS})
target_link_libraries(deep_miner_gui
Threads::Threads
SDL2::SDL2
SDL2_ttf::SDL2_ttf
)
endif()
# Main game executable
add_executable(deep_miner
${LIB_SOURCES}
src/Game.cpp
main.cpp
)
target_link_libraries(deep_miner Threads::Threads)
# Test executable (no Game.cpp — tests target individual classes directly)
add_executable(deep_miner_tests
${LIB_SOURCES}
tests/test_all.cpp
)
# Register with CTest so `ctest` / `cmake --build . --target test` works
enable_testing()
add_test(NAME unit_tests COMMAND deep_miner_tests)