Android: add compilation with cmake (see bug 3918)
authorSylvain Becker <sylvain.becker@gmail.com>
Tue, 13 Aug 2019 15:49:01 +0200
changeset 6864ac6bc242c62
parent 684 ba45f00879ba
child 687 32208515f967
Android: add compilation with cmake (see bug 3918)
CMakeLists.txt
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/CMakeLists.txt	Tue Aug 13 15:49:01 2019 +0200
     1.3 @@ -0,0 +1,49 @@
     1.4 +cmake_minimum_required(VERSION 3.0)
     1.5 +project(SDL_image C)
     1.6 +
     1.7 +
     1.8 +if (ANDROID)
     1.9 +
    1.10 +    option(SUPPORT_JPG "Support loading JPEG images" OFF)
    1.11 +    option(SUPPORT_PNG "Support loading PNG images" ON)
    1.12 +    option(SUPPORT_WEBP "Support loading WEBP images" OFF)
    1.13 +
    1.14 +    add_library(SDL_image SHARED)
    1.15 +    target_sources(SDL_image PRIVATE IMG.c IMG_png.c IMG_bmp.c IMG_gif.c
    1.16 +            IMG_jpg.c IMG_lbm.c IMG_pcx.c IMG_pnm.c IMG_svg.c IMG_tga.c
    1.17 +            IMG_tif.c IMG_webp.c IMG_WIC.c IMG_xcf.c IMG_xpm.c IMG_xv.c IMG_xxx.c)
    1.18 +
    1.19 +    add_definitions(
    1.20 +            -DLOAD_BMP -DLOAD_GIF -DLOAD_LBM -DLOAD_PCX -DLOAD_PNM
    1.21 +            -DLOAD_TGA -DLOAD_XCF -DLOAD_XPM -DLOAD_XV -DLOAD_XPM)
    1.22 +
    1.23 +    if (SUPPORT_JPG)
    1.24 +        add_definitions(-DLOAD_JPG)
    1.25 +        # missing CMakeFiles
    1.26 +        add_subdirectory(external/jpeg-9b)
    1.27 +
    1.28 +        target_link_libraries(SDL_image PRIVATE jpeg)
    1.29 +    endif()
    1.30 +
    1.31 +    if (SUPPORT_PNG)
    1.32 +        # missing libpng.vers
    1.33 +        set(HAVE_LD_VERSION_SCRIPT OFF CACHE BOOL "" FORCE)
    1.34 +        add_definitions(-DLOAD_PNG)
    1.35 +
    1.36 +        add_subdirectory(external/libpng-1.6.37)
    1.37 +        include_directories(external/libpng-1.6.37)
    1.38 +        target_link_libraries(SDL_image PRIVATE png)
    1.39 +    endif()
    1.40 +
    1.41 +    if (SUPPORT_WEBP)
    1.42 +        add_definitions(-DLOAD_WEBP)
    1.43 +        # missing cpufeatures
    1.44 +        add_subdirectory(external/libwebp-1.0.2)
    1.45 +        target_link_libraries(SDL_image PRIVATE webp)
    1.46 +    endif()
    1.47 +
    1.48 +    target_link_libraries(SDL_image PRIVATE SDL2)
    1.49 +else()
    1.50 +
    1.51 +endif()
    1.52 +