Skip to content

Commit

Permalink
Work on fetch sdl: only one fetch implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Dec 18, 2023
1 parent 99d8e00 commit 3476f87
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
25 changes: 0 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,6 @@ if (HELLOIMGUI_WITH_GLFW
endif()
endif()

# Shall we fetch sdl? (fill shall_fetch_sdl)
set(shall_fetch_sdl OFF)
if (HELLOIMGUI_WITH_SDL
AND NOT HELLOIMGUI_USE_SDL_SYSTEM_LIB
AND NOT TARGET sdl
AND NOT EMSCRIPTEN
)
find_package(SDL2 QUIET)
if (NOT SDL2_FOUND)
set(shall_fetch_sdl ON)
endif()
endif()


#------------------------------------------------------------------------------
# Download backend glfw or sdl if required
Expand All @@ -284,18 +271,6 @@ if (shall_fetch_glfw)
set(need_fetch_make_available_glfw ON)
endif()

if (shall_fetch_sdl)
message(STATUS "HelloImGui: downloading and building SDL")
include(FetchContent)
Set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(sdl
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG release-2.24.2
GIT_PROGRESS TRUE
)
set(need_fetch_make_available_sdl ON)
endif()

if (NOT (HELLOIMGUI_USE_SDL_OPENGL3 OR HELLOIMGUI_USE_GLFW_OPENGL3 OR HELLOIMGUI_CREATE_ANDROID_STUDIO_PROJECT))
message(FATAL_ERROR "Select at least one backend: use either
-DHELLOIMGUI_USE_SDL_OPENGL3=ON
Expand Down
22 changes: 20 additions & 2 deletions src/hello_imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,31 @@ endfunction()


function(_him_fetch_sdl_if_needed)
set(shall_fetch_sdl OFF)

# Always fetch SDL for iOS and Android
if (HELLOIMGUI_USE_SDL_OPENGL3 AND (IOS OR ANDROID))
set(shall_fetch_sdl ON)
endif()

# Fetch SDL if:
# option HELLOIMGUI_WITH_SDL was passed
# and SDL not available by find_package
# and HELLOIMGUI_USE_SDL_SYSTEM_LIB is OFF
if (HELLOIMGUI_WITH_SDL AND NOT HELLOIMGUI_USE_SDL_SYSTEM_LIB
AND NOT TARGET sdl AND NOT EMSCRIPTEN)
find_package(SDL2 QUIET)
if (NOT SDL2_FOUND)
set(shall_fetch_sdl ON)
endif()
endif()

if (shall_fetch_sdl)
_him_fetch_declare_sdl()
if(ANDROID)
FetchContent_Populate(sdl)
_him_prepare_android_sdl_symlink()
endif()
if(IOS)
else()
FetchContent_MakeAvailable(sdl)
endif()
endif()
Expand Down

0 comments on commit 3476f87

Please sign in to comment.