From 60d2db42c8c683c1467902d9c96509dd55a64b89 Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Mon, 18 Dec 2023 07:51:09 +0100 Subject: [PATCH] cmake: add link_opengl_sdl / part 1 --- src/hello_imgui/CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hello_imgui/CMakeLists.txt b/src/hello_imgui/CMakeLists.txt index f9b5d646..1fafd4ac 100644 --- a/src/hello_imgui/CMakeLists.txt +++ b/src/hello_imgui/CMakeLists.txt @@ -49,6 +49,15 @@ 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) @@ -56,13 +65,11 @@ function(link_sdl target) 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() @@ -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()