Skip to content

Commit

Permalink
cmake: add link_opengl_sdl / part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Dec 18, 2023
1 parent 8142dbc commit 60d2db4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/hello_imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,27 @@ if (EMSCRIPTEN)
endif()


function(link_opengl_sdl target)
if(IOS)
target_link_libraries(${target} PUBLIC "-framework OpenGLES")
elseif(ANDROID)
target_link_libraries(${target} PUBLIC GLESv3)
endif()
endfunction()


function(link_sdl target)
if (need_fetch_make_available_sdl)
FetchContent_MakeAvailable(sdl)
endif()

if(IOS)
target_link_libraries(${target} PUBLIC SDL2-static SDL2main)
target_link_libraries(${target} PUBLIC "-framework OpenGLES")
elseif(EMSCRIPTEN)
target_compile_options(${target} PUBLIC -s USE_SDL=2)
target_link_options(${target} INTERFACE -s USE_SDL=2)
elseif(ANDROID)
target_link_libraries(${target} PUBLIC SDL2main SDL2)
target_link_libraries(${target_name} PUBLIC GLESv3)
elseif(TARGET SDL2-static)
target_link_libraries(${target} PUBLIC SDL2-static)
else()
Expand All @@ -81,6 +88,7 @@ function(link_sdl target)
endif()
endif()

link_opengl_sdl(${target})
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
target_link_libraries(${target} PUBLIC Xext X11)
endif()
Expand Down

0 comments on commit 60d2db4

Please sign in to comment.