sdl2 now working again I think, but with better cmake

This commit is contained in:
herbglitch 2024-02-08 17:47:32 -07:00
parent c822075173
commit 3e15b6dfd0
16 changed files with 78 additions and 52 deletions

View file

@ -1,5 +1,6 @@
set(ARCHEUS_STD_SDL2_WINDOW_SOURCES
src/graphics/sdl/window.c
src/graphics/sdl/renderer.c
)
set(ARCHEUS_STD_SDL2_INPUT_SOURCES
@ -13,13 +14,12 @@ set(ARCHEUS_STD_SDL2_GRAPHICS_SOURCES
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)
function(sdl2_check_and_init_needed _ARCHEUS_STD_FLAGS _ARCHEUS_STD_SOURCES _ARCHEUS_STD_INCLUDE_DIRECTORIES _ARCHEUS_STD_LINK_LIBRARIES ARCHEUS_STD_WINDOW_BACKEND ARCHEUS_STD_INPUT_BACKEND ARCHEUS_STD_GRAPHICS_BACKEND)
#if no backend uses sdl return
if(NOT ${ARCHEUS_STD_WINDOW_BACKEND} STREQUAL "SDL2" AND NOT ${ARCHEUS_STD_INPUT_BACKEND} STREQUAL "SDL2" AND NOT ${ARCHEUS_STD_GRAPHICS_BACKEND} STREQUAL "SDL2")
return()
@ -28,6 +28,16 @@ function(sdl2_check_and_init_needed ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ARCHEU
#get needed libraries for backends
find_package(SDL2 REQUIRED)
#add to include directories
list(APPEND ${_ARCHEUS_STD_INCLUDE_DIRECTORIES}
PRIVATE ${SDL2_INCLUDE_DIRS}
)
#add to link libraries
list(APPEND ${_ARCHEUS_STD_LINK_LIBRARIES}
PUBLIC ${SDL2_LIBRARIES}
)
#add matching files for the selected backends
if(${ARCHEUS_STD_WINDOW_BACKEND} STREQUAL "SDL2")
string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_SDL2_WINDOW ")
@ -45,16 +55,21 @@ function(sdl2_check_and_init_needed ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ARCHEU
string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_SDL2_GRAPHICS ")
list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_SDL2_GRAPHICS_SOURCES})
#add to include directories
list(APPEND ${_ARCHEUS_STD_INCLUDE_DIRECTORIES}
PRIVATE ${SDL2IMAGE_INCLUDE_DIRS}
)
#add to link libraries
list(APPEND ${_ARCHEUS_STD_LINK_LIBRARIES}
PUBLIC SDL2_image::SDL2_image
PUBLIC SDL2_ttf::SDL2_ttf
)
endif()
set(${_ARCHEUS_STD_FLAGS} ${${_ARCHEUS_STD_FLAGS}} PARENT_SCOPE)
set(${_ARCHEUS_STD_SOURCES} ${${_ARCHEUS_STD_SOURCES}} PARENT_SCOPE)
# target_include_directories(archeus_std
# PRIVATE ${SDL2_INCLUDE_DIRS}
# PRIVATE ${SDL2IMAGE_INCLUDE_DIRS}
# )
# target_link_libraries(archeus_std PUBLIC ${SDL2_LIBRARIES} SDL2_image::SDL2_image SDL2_ttf::SDL2_ttf)
set(${_ARCHEUS_STD_INCLUDE_DIRECTORIES} ${${_ARCHEUS_STD_INCLUDE_DIRECTORIES}} PARENT_SCOPE)
set(${_ARCHEUS_STD_LINK_LIBRARIES} ${${_ARCHEUS_STD_LINK_LIBRARIES}} PARENT_SCOPE)
endfunction()