CMake improvements: see if SDL2 target is defined; allow to build as a static library by eliasdaler · Pull Request #170 · libsdl-org/SDL_image (original) (raw)
Hello.
This patch fixes two problems that I've encountered with SDL_image.
- It didn't allow me to build it as a static library -
add_library
was called withSHARED
flag, soBUILD_SHARED_LIBS
had no effect. - I build SDL_image with SDL2 in a "superbuild" way by doing this:
add_subdirectory(sdl2_src) add_subdirectory(sdl_image_src)
Unfortunately, find_package
didn't allow me to do it, because SDL2 was not found system-wide (it's not built when I call add_subdirectory). However, if you don't call find_package
if SDL2
target is present, this will work, because SDL2 will be compiled later and will successfully link with SDL_image afterwards.