From 2c89fb106a779b80e258e75108b3433bf379d609 Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Thu, 8 Sep 2022 14:42:23 +0100 Subject: [PATCH] Attempt to use find_package for SDL2_image/_net --- 32blit-sdl/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/32blit-sdl/CMakeLists.txt b/32blit-sdl/CMakeLists.txt index 7c9d19220..91066940e 100644 --- a/32blit-sdl/CMakeLists.txt +++ b/32blit-sdl/CMakeLists.txt @@ -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