Skip to content

Commit

Permalink
Attempt to use find_package for SDL2_image/_net
Browse files Browse the repository at this point in the history
  • Loading branch information
Daft-Freak committed Sep 9, 2022
1 parent 91b83d4 commit 2c89fb1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 32blit-sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ add_library(BlitHalSDL STATIC
function (find_sdl_lib lib_name header_name)
string(TOUPPER ${lib_name} VAR_PREFIX)

# new enough SDL_image/_net have cmake config support
find_package(${lib_name} QUIET)
if(TARGET ${lib_name}::${lib_name})
set(${VAR_PREFIX}_LIBRARY ${lib_name}::${lib_name} PARENT_SCOPE)
set(${VAR_PREFIX}_INCLUDE_DIR "" PARENT_SCOPE)

if(WIN32)
get_property(LIB_DLL TARGET ${lib_name}::${lib_name} PROPERTY IMPORTED_LOCATION)
set(${VAR_PREFIX}_DLL ${LIB_DLL} PARENT_SCOPE)
endif()

return()
endif()

message("find_package(${lib_name}) failed, trying manual search...")

find_path(${VAR_PREFIX}_INCLUDE_DIR ${header_name}
HINTS ${SDL2_DIR} ${SDL2_DIR}/../../../
PATH_SUFFIXES SDL2 include/SDL2 include
Expand Down

0 comments on commit 2c89fb1

Please sign in to comment.