We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4623 - SDL2 Image CMake support
Summary: SDL2 Image CMake support
Status: RESOLVED FIXED
Alias: None
Product: SDL_image
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: x86_64 Windows 10
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-05 16:45 UTC by Kata
Modified: 2019-08-20 14:41 UTC (History)
2 users (show)

See Also:


Attachments
CMakeLists tree patch (5.48 KB, patch)
2019-08-20 02:42 UTC, krzysio.kurek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kata 2019-05-05 16:45:28 UTC
Hi, please add CMakeLists.txt for image library.
Comment 1 Kata 2019-05-05 16:46:56 UTC
Cmake list will help for the android build.
Comment 2 krzysio.kurek 2019-08-20 02:42:06 UTC
Created attachment 3929 [details]
CMakeLists tree patch

So there was a cmake tree already although it was mysteriously wrapped in `if(ANDROID)`, excluding any sort of usability on other platforms. This patch should enable easier embedding of the library in projects using cmake, although a sdl2image-config.cmake.in or something similiar would probably be in place.
Comment 3 Sylvain 2019-08-20 07:58:00 UTC
I have added a few CMakeLists.txt, but I only tested them on android, I added this if(ANDROID) for this reason.
see bug 3918

They were some difference between android and other platform. Like: 

quoting:
"so you should have "target_link_libraries(yourgame SDL2 SDL2main)"
in your CMakeLists.txt file. Also be aware that you should use add_library() instead of
add_executable() for the target containing your "main" function."


maybe this doesn't applied to libraries.

Did you also try you patch with Android ? other platform ? 

If you want full CMake support, there are also SDL_ttf and SDL_mixer which have been updated
Comment 4 Sylvain 2019-08-20 08:20:45 UTC
The FindPackage failed for Android, I am not sure how to fix it:
  

CMake Error at SDL_image/CMakeLists.txt:4 (find_package):
    By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has
    asked CMake to find a package configuration file provided by "SDL2", but
    CMake did not find one.
  
    Could not find a package configuration file provided by "SDL2" with any of
    the following names:
  
      SDL2Config.cmake
      sdl2-config.cmake
Comment 5 Sylvain 2019-08-20 09:49:50 UTC
modified cmakelists for jpeg is included here: https://hg.libsdl.org/SDL_image/rev/2d55bf825f71
Comment 6 Sylvain 2019-08-20 09:56:01 UTC
also added the SDL_image cmake modified to still compile on android
https://hg.libsdl.org/SDL_image/rev/5fcbadcc4090
Comment 7 krzysio.kurek 2019-08-20 14:41:58 UTC
I have not tried the patch with any other platform unfortunately, but I'm also pretty sure that I haven't introduced any changes that would be breaking compared to the currently existing solution.
The FindSDL2 error is caused by me quite stupidly assuming that SDL2 would be installed through CMake on the system already.