archeus/cmake/archeus_sdl2.cmake

60 lines
2.1 KiB
CMake
Raw Normal View History

2024-01-12 19:48:17 -07:00
set(ARCHEUS_STD_SDL2_WINDOW_SOURCES
2024-02-08 16:53:31 -07:00
src/graphics/sdl/window.c
2024-01-12 19:48:17 -07:00
)
set(ARCHEUS_STD_SDL2_INPUT_SOURCES
src/input/sdl/keyboard.c
src/input/sdl/mouse.c
)
set(ARCHEUS_STD_SDL2_GRAPHICS_SOURCES
src/graphics/sdl/circle.c
src/graphics/sdl/config.c
src/graphics/sdl/line.c
src/graphics/sdl/obround.c
src/graphics/sdl/rectangle.c
src/graphics/sdl/renderer.c
src/graphics/sdl/sprite.c
src/graphics/sdl/spritesheet.c
src/graphics/sdl/text.c
)
function(sdl2_check_and_init_needed ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ARCHEUS_STD_WINDOW_BACKEND ARCHEUS_STD_INPUT_BACKEND ARCHEUS_STD_GRAPHICS_BACKEND)
#if no backend uses sdl return
2024-02-08 16:53:31 -07:00
if(NOT ${ARCHEUS_STD_WINDOW_BACKEND} STREQUAL "SDL2" AND NOT ${ARCHEUS_STD_INPUT_BACKEND} STREQUAL "SDL2" AND NOT ${ARCHEUS_STD_GRAPHICS_BACKEND} STREQUAL "SDL2")
2024-01-12 19:48:17 -07:00
return()
endif()
#get needed libraries for backends
find_package(SDL2 REQUIRED)
#add matching files for the selected backends
2024-02-08 16:53:31 -07:00
if(${ARCHEUS_STD_WINDOW_BACKEND} STREQUAL "SDL2")
string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_SDL2_WINDOW ")
list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_SDL2_WINDOW_SOURCES})
2024-01-12 19:48:17 -07:00
endif()
2024-02-08 16:53:31 -07:00
if(${ARCHEUS_STD_INPUT_BACKEND} STREQUAL "SDL2")
string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_SDL2_INPUT ")
list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_SDL2_INPUT_SOURCES})
2024-01-12 19:48:17 -07:00
endif()
2024-02-08 16:53:31 -07:00
if(${ARCHEUS_STD_GRAPHICS_BACKEND} STREQUAL "SDL2")
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)
string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_SDL2_GRAPHICS ")
list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_SDL2_GRAPHICS_SOURCES})
2024-01-12 19:48:17 -07:00
endif()
2024-02-08 16:53:31 -07:00
set(${_ARCHEUS_STD_FLAGS} ${${_ARCHEUS_STD_FLAGS}} PARENT_SCOPE)
set(${_ARCHEUS_STD_SOURCES} ${${_ARCHEUS_STD_SOURCES}} PARENT_SCOPE)
2024-01-12 19:48:17 -07:00
2024-02-08 16:53:31 -07:00
# target_include_directories(archeus_std
# PRIVATE ${SDL2_INCLUDE_DIRS}
# PRIVATE ${SDL2IMAGE_INCLUDE_DIRS}
# )
2024-01-12 19:48:17 -07:00
2024-02-08 16:53:31 -07:00
# target_link_libraries(archeus_std PUBLIC ${SDL2_LIBRARIES} SDL2_image::SDL2_image SDL2_ttf::SDL2_ttf)
2024-01-12 19:48:17 -07:00
endfunction()