cmake: fix vwebp_sdl compile w/libsdl-org release

Prebuilt SDL2 releases from https://github.com/libsdl-org/SDL/releases
provide include/SDL.h. Test for this and set WEBP_HAVE_JUST_SDL_H
accordingly.

This was inspired by:
d0b3e8efe3/ports/libwebp/0008-sdl.patch

Bug: b:301040580
Change-Id: I320ed1a23352fc4035d491399fdba184dc927554
Test: cmake .. -DCMAKE_PREFIX_PATH=<path-to-sdl2>/cmake
This commit is contained in:
James Zern 2024-03-28 14:11:46 -07:00
parent 6c484cbf92
commit d537cd3704

View File

@ -665,6 +665,21 @@ if(WEBP_BUILD_EXTRAS)
${CMAKE_CURRENT_BINARY_DIR}/src ${SDL2_INCLUDE_DIRS}) ${CMAKE_CURRENT_BINARY_DIR}/src ${SDL2_INCLUDE_DIRS})
set(WEBP_HAVE_SDL 1) set(WEBP_HAVE_SDL 1)
target_compile_definitions(vwebp_sdl PUBLIC WEBP_HAVE_SDL) target_compile_definitions(vwebp_sdl PUBLIC WEBP_HAVE_SDL)
set(CMAKE_REQUIRED_INCLUDES "${SDL2_INCLUDE_DIRS}")
check_c_source_compiles(
"
#define SDL_MAIN_HANDLED
#include \"SDL.h\"
int main(void) {
return 0;
}
"
HAVE_JUST_SDL_H)
set(CMAKE_REQUIRED_INCLUDES)
if(HAVE_JUST_SDL_H)
target_compile_definitions(vwebp_sdl PRIVATE WEBP_HAVE_JUST_SDL_H)
endif()
endif() endif()
endif() endif()