2025-02-08 02:15:23 -07:00
|
|
|
set(ARCHEUS_SDL2_WINDOW_SOURCES
|
2025-03-19 05:13:11 -06:00
|
|
|
packages/graphics/sdl/config.c
|
2024-05-20 03:46:04 -06:00
|
|
|
packages/graphics/sdl/window.c
|
|
|
|
|
packages/graphics/sdl/renderer.c
|
2024-01-12 19:48:17 -07:00
|
|
|
)
|
|
|
|
|
|
2025-02-08 02:15:23 -07:00
|
|
|
set(ARCHEUS_SDL2_INPUT_SOURCES
|
2024-05-20 03:46:04 -06:00
|
|
|
packages/input/sdl/input.c
|
|
|
|
|
packages/input/sdl/keyboard.c
|
|
|
|
|
packages/input/sdl/mouse.c
|
2024-08-28 02:57:29 -06:00
|
|
|
|
|
|
|
|
#TODO: remove this
|
|
|
|
|
packages/audio/sdl/config.c
|
2024-01-12 19:48:17 -07:00
|
|
|
)
|
|
|
|
|
|
2025-02-08 02:15:23 -07:00
|
|
|
set(ARCHEUS_SDL2_GRAPHICS_SOURCES
|
2024-05-20 03:46:04 -06:00
|
|
|
packages/graphics/sdl/circle.c
|
|
|
|
|
packages/graphics/sdl/config.c
|
|
|
|
|
packages/graphics/sdl/line.c
|
|
|
|
|
packages/graphics/sdl/obround.c
|
|
|
|
|
packages/graphics/sdl/rectangle.c
|
|
|
|
|
packages/graphics/sdl/sprite.c
|
|
|
|
|
packages/graphics/sdl/spritesheet.c
|
|
|
|
|
packages/graphics/sdl/text.c
|
2024-01-12 19:48:17 -07:00
|
|
|
)
|
|
|
|
|
|
2025-02-08 02:15:23 -07:00
|
|
|
function(sdl2_check_and_init_needed _ARCHEUS_SOURCES _ARCHEUS_INCLUDE_DIRECTORIES _ARCHEUS_LINK_LIBRARIES ARCHEUS_WINDOW_BACKEND ARCHEUS_INPUT_BACKEND ARCHEUS_GRAPHICS_BACKEND)
|
2024-01-12 19:48:17 -07:00
|
|
|
#if no backend uses sdl return
|
2025-02-08 02:15:23 -07:00
|
|
|
if(NOT ${ARCHEUS_WINDOW_BACKEND} STREQUAL "SDL2" AND NOT ${ARCHEUS_INPUT_BACKEND} STREQUAL "SDL2" AND NOT ${ARCHEUS_GRAPHICS_BACKEND} STREQUAL "SDL2")
|
2024-01-12 19:48:17 -07:00
|
|
|
return()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
#get needed libraries for backends
|
|
|
|
|
find_package(SDL2 REQUIRED)
|
|
|
|
|
|
2024-02-08 17:47:32 -07:00
|
|
|
#add to include directories
|
2025-02-08 02:15:23 -07:00
|
|
|
list(APPEND ${_ARCHEUS_INCLUDE_DIRECTORIES}
|
2024-02-08 17:47:32 -07:00
|
|
|
PRIVATE ${SDL2_INCLUDE_DIRS}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
#add to link libraries
|
2025-02-08 02:15:23 -07:00
|
|
|
list(APPEND ${_ARCHEUS_LINK_LIBRARIES}
|
2024-02-08 17:47:32 -07:00
|
|
|
PUBLIC ${SDL2_LIBRARIES}
|
|
|
|
|
)
|
|
|
|
|
|
2024-01-12 19:48:17 -07:00
|
|
|
#add matching files for the selected backends
|
2025-02-08 02:15:23 -07:00
|
|
|
if(${ARCHEUS_WINDOW_BACKEND} STREQUAL "SDL2")
|
|
|
|
|
list(APPEND ${_ARCHEUS_SOURCES} ${ARCHEUS_SDL2_WINDOW_SOURCES})
|
2024-01-12 19:48:17 -07:00
|
|
|
endif()
|
|
|
|
|
|
2025-02-08 02:15:23 -07:00
|
|
|
if(${ARCHEUS_INPUT_BACKEND} STREQUAL "SDL2")
|
2024-08-28 02:57:29 -06:00
|
|
|
#TODO: remove this
|
|
|
|
|
find_package(SDL2_mixer REQUIRED)
|
|
|
|
|
|
2025-02-08 02:15:23 -07:00
|
|
|
list(APPEND ${_ARCHEUS_SOURCES} ${ARCHEUS_SDL2_INPUT_SOURCES})
|
2024-08-28 02:57:29 -06:00
|
|
|
|
|
|
|
|
#TODO: remove this
|
2025-02-08 02:15:23 -07:00
|
|
|
list(APPEND ${_ARCHEUS_LINK_LIBRARIES}
|
2024-08-28 02:57:29 -06:00
|
|
|
PUBLIC SDL2_mixer::SDL2_mixer
|
|
|
|
|
)
|
2024-01-12 19:48:17 -07:00
|
|
|
endif()
|
|
|
|
|
|
2025-02-08 02:15:23 -07:00
|
|
|
if(${ARCHEUS_GRAPHICS_BACKEND} STREQUAL "SDL2")
|
2024-02-08 16:53:31 -07:00
|
|
|
find_package(SDL2_image REQUIRED)
|
|
|
|
|
find_package(SDL2_ttf REQUIRED)
|
|
|
|
|
|
2025-02-11 00:57:39 -07:00
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
|
pkg_check_modules(SDL2_GFX REQUIRED SDL2_gfx)
|
|
|
|
|
|
2025-02-08 02:15:23 -07:00
|
|
|
list(APPEND ${_ARCHEUS_SOURCES} ${ARCHEUS_SDL2_GRAPHICS_SOURCES})
|
2024-02-08 17:47:32 -07:00
|
|
|
|
|
|
|
|
#add to include directories
|
2025-02-08 02:15:23 -07:00
|
|
|
list(APPEND ${_ARCHEUS_INCLUDE_DIRECTORIES}
|
2024-02-08 17:47:32 -07:00
|
|
|
PRIVATE ${SDL2IMAGE_INCLUDE_DIRS}
|
2025-02-11 00:57:39 -07:00
|
|
|
PRIVATE ${SDL2_GFX_INCLUDE_DIRS}
|
2024-02-08 17:47:32 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
#add to link libraries
|
2025-02-08 02:15:23 -07:00
|
|
|
list(APPEND ${_ARCHEUS_LINK_LIBRARIES}
|
2024-02-08 17:47:32 -07:00
|
|
|
PUBLIC SDL2_image::SDL2_image
|
|
|
|
|
PUBLIC SDL2_ttf::SDL2_ttf
|
2025-02-11 00:57:39 -07:00
|
|
|
PUBLIC ${SDL2_GFX_LIBRARIES}
|
2024-02-08 17:47:32 -07:00
|
|
|
)
|
2024-01-12 19:48:17 -07:00
|
|
|
endif()
|
|
|
|
|
|
2025-02-08 02:15:23 -07:00
|
|
|
set(${_ARCHEUS_SOURCES} ${${_ARCHEUS_SOURCES}} PARENT_SCOPE)
|
|
|
|
|
set(${_ARCHEUS_INCLUDE_DIRECTORIES} ${${_ARCHEUS_INCLUDE_DIRECTORIES}} PARENT_SCOPE)
|
|
|
|
|
set(${_ARCHEUS_LINK_LIBRARIES} ${${_ARCHEUS_LINK_LIBRARIES}} PARENT_SCOPE)
|
2024-08-28 02:57:29 -06:00
|
|
|
endfunction()
|