File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,25 +12,36 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
1212 add_compile_definitions (CF_DEBUG )
1313endif ()
1414
15- # ── SDL3 ────────────────────────────────────────────────────── ──
16- find_package (SDL3 REQUIRED CONFIG )
15+ # ── SDL3 (optional – RHI is only built when SDL3 is available) ──
16+ find_package (SDL3 CONFIG QUIET )
1717
1818add_library (Caffeine
1919 src/core/Timer.cpp
2020 src/core/GameLoop.cpp
2121 src/input/InputManager.cpp
2222 src/debug/LogSystem.cpp
2323 src/debug/Profiler.cpp
24- src/rhi/RenderDevice.cpp
25- src/rhi/CommandBuffer.cpp
2624)
2725
26+ if (SDL3_FOUND)
27+ target_sources (Caffeine PRIVATE
28+ src/rhi/RenderDevice.cpp
29+ src/rhi/CommandBuffer.cpp
30+ )
31+ endif ()
32+
2833target_include_directories (Caffeine PUBLIC
2934 $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR} /src >
3035 $<INSTALL_INTERFACE :include >
3136)
3237
33- target_link_libraries (Caffeine PUBLIC SDL3::SDL3 )
38+ if (SDL3_FOUND)
39+ target_link_libraries (Caffeine PUBLIC SDL3::SDL3 )
40+ target_compile_definitions (Caffeine PUBLIC CF_HAS_SDL3=1 )
41+ message (STATUS "SDL3 found – RHI module enabled" )
42+ else ()
43+ message (STATUS "SDL3 not found – RHI module disabled" )
44+ endif ()
3445
3546target_compile_features (Caffeine PUBLIC cxx_std_20 )
3647
Original file line number Diff line number Diff line change 11cmake_minimum_required (VERSION 3.20 )
22
3- add_executable ( CaffeineTest
3+ set (CAFFEINE_TEST_SOURCES
44 test_allocators.cpp
55 test_containers.cpp
66 test_math.cpp
@@ -9,9 +9,14 @@ add_executable(CaffeineTest
99 test_gameloop.cpp
1010 test_input.cpp
1111 test_debug.cpp
12- test_rhi.cpp
1312)
1413
14+ if (SDL3_FOUND)
15+ list (APPEND CAFFEINE_TEST_SOURCES test_rhi.cpp)
16+ endif ()
17+
18+ add_executable (CaffeineTest ${CAFFEINE_TEST_SOURCES} )
19+
1520target_link_libraries (CaffeineTest PRIVATE Caffeine )
1621target_include_directories (CaffeineTest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} /Catch2 )
1722if (MSVC )
@@ -23,10 +28,10 @@ endif()
2328enable_testing ()
2429add_test (NAME CaffeineTest COMMAND CaffeineTest )
2530
26- if (WIN32 )
31+ if (SDL3_FOUND AND WIN32 )
2732 add_custom_command (TARGET CaffeineTest POST_BUILD
2833 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2934 $<TARGET_FILE :SDL3 ::SDL3 >
3035 $<TARGET_FILE_DIR :CaffeineTest >
3136 )
32- endif ()
37+ endif ()
You can’t perform that action at this time.
0 commit comments