build: fix finding SDL2 on vcpkg (again)
Sometimes vcpkg calls the SDL2 library SDL2-static for static toolchains and sometimes it doesn't, change FindSDL2.cmake to search some possible library names in order of priority. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
1a687e564b
commit
5807376fba
|
@ -109,19 +109,31 @@ if(SDL2_STATIC)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
unset(lib_suffix)
|
||||
unset(lib_suffixes)
|
||||
if(MSVC)
|
||||
if(VCPKG_TARGET_TRIPLET MATCHES "-static$")
|
||||
set(lib_suffix "${lib_suffix}-static")
|
||||
list(APPEND lib_suffixes -static)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
|
||||
set(lib_suffix "${lib_suffix}d")
|
||||
list(APPEND lib_suffixes d)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Calculate combination of possible name+suffixes.
|
||||
unset(names)
|
||||
set(lib_name SDL2)
|
||||
set(current ${lib_name})
|
||||
foreach(suffix ${lib_suffixes})
|
||||
list(APPEND names "${current}${suffix}" "${lib_name}${suffix}")
|
||||
set(current "${current}${suffix}")
|
||||
endforeach()
|
||||
|
||||
# Fallback to name by itself.
|
||||
list(APPEND names ${lib_name})
|
||||
|
||||
FIND_LIBRARY(SDL2_LIBRARY_TEMP
|
||||
NAMES SDL2${lib_suffix}
|
||||
NAMES ${names}
|
||||
HINTS $ENV{SDL2DIR}
|
||||
PATH_SUFFIXES lib64 lib lib/x64 lib/x86
|
||||
PATHS ${SDL2_SEARCH_PATHS}
|
||||
|
|
Loading…
Reference in New Issue