Skip to content

Commit

Permalink
_him_link_sdl: use find_package on desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Dec 31, 2023
1 parent 3fc8000 commit 8abe2c9
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/hello_imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ endfunction()
###################################################################################################
function (him_use_sdl2_backend target)
_him_fetch_sdl_if_needed()
# _him_fail_if_sdl_not_found()
_him_link_sdl(${helloimgui_target})

target_sources(${target} PRIVATE
Expand All @@ -443,7 +444,6 @@ function (him_use_sdl2_backend target)
target_compile_definitions(${helloimgui_target} PUBLIC _THREAD_SAFE) # flag outputted by sdl2-config --cflags
endfunction()


function(_him_fetch_sdl_if_needed)
set(shall_fetch_sdl OFF)

Expand Down Expand Up @@ -517,19 +517,8 @@ function(_him_link_sdl target)
elseif(TARGET SDL2-static)
target_link_libraries(${target} PUBLIC SDL2-static)
else()
find_package(SDL2)
if (SDL2_FOUND AND (TARGET SDL2::SDL2))
target_link_libraries(${target} PUBLIC SDL2::SDL2 SDL2::SDL2main)
else()
if (NOT DEFINED SDL2_INCLUDE_DIRS)
set(SDL2_INCLUDE_DIRS /usr/include/SDL2)
endif()
target_include_directories(${target} PUBLIC ${SDL2_INCLUDE_DIRS})
if (DEFINED SDL2_LIBDIR)
target_link_directories(${target} PUBLIC ${SDL2_LIBDIR})
endif()
target_link_libraries(${target} PUBLIC SDL2 SDL2main)
endif()
find_package(SDL2 REQUIRED)
target_link_libraries(${target} PUBLIC SDL2::SDL2 SDL2::SDL2main)
endif()

if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
Expand Down

0 comments on commit 8abe2c9

Please sign in to comment.