diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f357c6ed..0b31b4bd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,9 +16,9 @@ jobs: matrix: platform: - { name: Windows (MSVC), os: windows-latest, shell: sh, vendored: true, msvc: 1, shared: 1, static: 0, artifact: 'SDL3_image-VC-x64', - cmake: '-DSDL3IMAGE_BACKEND_STB=OFF -DPerl_ROOT=C:/Strawberry/perl/bin/ -GNinja -DCMAKE_POLICY_DEFAULT_CMP0141=NEW -DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=ProgramDatabase -DCMAKE_EXE_LINKER_FLAGS=-DEBUG -DCMAKE_SHARED_LINKER_FLAGS=-DEBUG' } + cmake: '-DSDLIMAGE_BACKEND_STB=OFF -DPerl_ROOT=C:/Strawberry/perl/bin/ -GNinja -DCMAKE_POLICY_DEFAULT_CMP0141=NEW -DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=ProgramDatabase -DCMAKE_EXE_LINKER_FLAGS=-DEBUG -DCMAKE_SHARED_LINKER_FLAGS=-DEBUG' } - { name: Windows (mingw64), os: windows-latest, shell: 'msys2 {0}', vendored: false, msystem: mingw64, msys-env: mingw-w64-x86_64, shared: 1, static: 0, artifact: 'SDL3_image-mingw64', - cmake: '-DSDL3IMAGE_BACKEND_STB=OFF -DSDL3IMAGE_BACKEND_WIC=OFF -DSDL3IMAGE_AVIF=ON -G "Ninja Multi-Config"' } + cmake: '-DSDLIMAGE_BACKEND_STB=OFF -DSDLIMAGE_BACKEND_WIC=OFF -DSDLIMAGE_AVIF=ON -G "Ninja Multi-Config"' } - { name: Linux, os: ubuntu-latest, shell: sh, vendored: false, cmake: '-GNinja', shared: 1, static: 0, noavif: true, nojxl: true, artifact: 'SDL3_image-linux-x64' } - { name: 'Linux (static)', os: ubuntu-latest, shell: sh, vendored: true, cmake: '-DBUILD_SHARED_LIBS=OFF -GNinja', shared: 0, static: 1, artifact: 'SDL3_image-static-linux-x64' } - { name: Macos, os: macos-latest, shell: sh, vendored: false, cmake: '-GNinja', shared: 1, static: 0, artifact: 'SDL3_image-macos' } @@ -97,19 +97,19 @@ jobs: run: | export CMAKE_CONFIGURATION_TYPES=Release cmake -B build \ - -DSDL3IMAGE_VENDORED=${{ matrix.platform.vendored }} \ + -DSDLIMAGE_VENDORED=${{ matrix.platform.vendored }} \ -DBUILD_SHARED_LIBS=ON \ -DCMAKE_BUILD_TYPE=Release \ - -DSDL3IMAGE_SAMPLES=ON \ - -DSDL3IMAGE_TESTS=ON \ - -DSDL3IMAGE_TESTS_INSTALL=ON \ - -DSDL3IMAGE_AVIF=${{ !matrix.platform.noavif }} \ - -DSDL3IMAGE_JXL=${{ !matrix.platform.nojxl }} \ - -DSDL3IMAGE_TIF=ON \ - -DSDL3IMAGE_WEBP=ON \ - -DSDL3IMAGE_STRICT=ON \ - -DSDL3IMAGE_WERROR=ON \ - -DSDL3IMAGE_INSTALL_MAN=ON \ + -DSDLIMAGE_SAMPLES=ON \ + -DSDLIMAGE_TESTS=ON \ + -DSDLIMAGE_TESTS_INSTALL=ON \ + -DSDLIMAGE_AVIF=${{ !matrix.platform.noavif }} \ + -DSDLIMAGE_JXL=${{ !matrix.platform.nojxl }} \ + -DSDLIMAGE_TIF=ON \ + -DSDLIMAGE_WEBP=ON \ + -DSDLIMAGE_STRICT=ON \ + -DSDLIMAGE_WERROR=ON \ + -DSDLIMAGE_INSTALL_MAN=ON \ -DCMAKE_INSTALL_PREFIX=prefix_cmake \ -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=$PWD/build \ -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=$PWD/build \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 81c8529a..88ba575c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,14 +27,14 @@ sdl_calculate_derived_version_variables(${MAJOR_VERSION} ${MINOR_VERSION} ${MICR message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}") if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) - set(SDL3IMAGE_ROOTPROJECT ON) + set(SDLIMAGE_ROOTPROJECT ON) else() - set(SDL3IMAGE_ROOTPROJECT OFF) + set(SDLIMAGE_ROOTPROJECT OFF) endif() -set(SDL3IMAGE_SAMPLES_DEFAULT ${SDL3IMAGE_ROOTPROJECT}) +set(SDLIMAGE_SAMPLES_DEFAULT ${SDLIMAGE_ROOTPROJECT}) if(ANDROID) - set(SDL3IMAGE_SAMPLES_DEFAULT OFF) + set(SDLIMAGE_SAMPLES_DEFAULT OFF) endif() # Assume MSVC projects don't have a package manager and need vendored dependencies (by default). @@ -45,10 +45,10 @@ else() set(vendored_default OFF) endif() -set(sdl3image_install_enableable ON) +set(sdlimage_install_enableable ON) if((TARGET SDL3-shared OR TARGET SDL3-static) AND SDL_DISABLE_INSTALL) # Cannot install SDL3_image when SDL3 is built in same built, and is not installed. - set(sdl3image_install_enableable OFF) + set(sdlimage_install_enableable OFF) endif() if(NOT DEFINED CMAKE_FIND_PACKAGE_PREFER_CONFIG) @@ -67,144 +67,144 @@ endif() option(CMAKE_POSITION_INDEPENDENT_CODE "Build static libraries with -fPIC" ${PLATFORM_SUPPORTS_SHARED}) cmake_dependent_option(BUILD_SHARED_LIBS "Build the library as a shared library" ON PLATFORM_SUPPORTS_SHARED OFF) -cmake_dependent_option(SDL3IMAGE_INSTALL "Enable SDL3_image install target" ${SDL3IMAGE_ROOTPROJECT} "${sdl3image_install_enableable}" OFF) -cmake_dependent_option(SDL3IMAGE_INSTALL_CPACK "Create binary SDL3_image archive using CPack" ${SDL3IMAGE_ROOTPROJECT} "SDL3IMAGE_INSTALL" OFF) -cmake_dependent_option(SDL3IMAGE_INSTALL_MAN "Install man pages for SDL3_image" OFF "SDL3IMAGE_INSTALL" OFF) -cmake_dependent_option(SDL3IMAGE_DEPS_SHARED "Load dependencies dynamically" ON PLATFORM_SUPPORTS_SHARED OFF) -option(SDL3IMAGE_VENDORED "Use vendored third-party libraries" ${vendored_default}) -option(SDL3IMAGE_WERROR "Treat warnings as errors" OFF) +cmake_dependent_option(SDLIMAGE_INSTALL "Enable SDL3_image install target" ${SDLIMAGE_ROOTPROJECT} "${sdlimage_install_enableable}" OFF) +cmake_dependent_option(SDLIMAGE_INSTALL_CPACK "Create binary SDL3_image archive using CPack" ${SDLIMAGE_ROOTPROJECT} "SDLIMAGE_INSTALL" OFF) +cmake_dependent_option(SDLIMAGE_INSTALL_MAN "Install man pages for SDL3_image" OFF "SDLIMAGE_INSTALL" OFF) +cmake_dependent_option(SDLIMAGE_DEPS_SHARED "Load dependencies dynamically" ON PLATFORM_SUPPORTS_SHARED OFF) +option(SDLIMAGE_VENDORED "Use vendored third-party libraries" ${vendored_default}) +option(SDLIMAGE_WERROR "Treat warnings as errors" OFF) -option(SDL3IMAGE_STRICT "Fail when a dependency could not be found" OFF) +option(SDLIMAGE_STRICT "Fail when a dependency could not be found" OFF) set(required "") set(fatal_error "STATUS") -if(SDL3IMAGE_STRICT) +if(SDLIMAGE_STRICT) set(required "REQUIRED") set(fatal_error "FATAL_ERROR") endif() -option(SDL3IMAGE_SAMPLES "Build the SDL3_image sample program(s)" ${SDL3IMAGE_SAMPLES_DEFAULT}) -cmake_dependent_option(SDL3IMAGE_SAMPLES_INSTALL "Install the SDL3_image sample program(s)" OFF "SDL3IMAGE_SAMPLES;SDL3IMAGE_INSTALL" OFF) - -option(SDL3IMAGE_TESTS "Build unit tests?" OFF) -option(SDL3IMAGE_TESTS_INSTALL "Install unit tests?" OFF) - -option(SDL3IMAGE_BACKEND_STB "Use stb_image for loading JPEG and PNG files" ON) -cmake_dependent_option(SDL3IMAGE_BACKEND_WIC "Add WIC backend (Windows Imaging Component)" OFF WIN32 OFF) -cmake_dependent_option(SDL3IMAGE_BACKEND_IMAGEIO "Use native Mac OS X frameworks for loading images" ON APPLE OFF) - -option(SDL3IMAGE_AVIF "Support loading AVIF images" ON) -option(SDL3IMAGE_BMP "Support loading BMP images" ON) -option(SDL3IMAGE_GIF "Support loading GIF images" ON) -option(SDL3IMAGE_JPG "Support loading JPEG images" ON) -option(SDL3IMAGE_JXL "Support loading JXL images" OFF) -option(SDL3IMAGE_LBM "Support loading LBM images" ON) -option(SDL3IMAGE_PCX "Support loading PCX images" ON) -option(SDL3IMAGE_PNG "Support loading PNG images" ON) -option(SDL3IMAGE_PNM "Support loading PNM images" ON) -option(SDL3IMAGE_QOI "Support loading QOI images" ON) -option(SDL3IMAGE_SVG "Support loading SVG images" ON) -option(SDL3IMAGE_TGA "Support loading TGA images" ON) -option(SDL3IMAGE_TIF "Support loading TIFF images" ON) -option(SDL3IMAGE_WEBP "Support loading WEBP images" ON) -option(SDL3IMAGE_XCF "Support loading XCF images" ON) -option(SDL3IMAGE_XPM "Support loading XPM images" ON) -option(SDL3IMAGE_XV "Support loading XV images" ON) - -cmake_dependent_option(SDL3IMAGE_AVIF_SAVE "Add AVIF save support" ON SDL3IMAGE_AVIF OFF) -cmake_dependent_option(SDL3IMAGE_JPG_SAVE "Add JPEG save support" ON SDL3IMAGE_JPG OFF) -cmake_dependent_option(SDL3IMAGE_PNG_SAVE "Add PNG save support" ON SDL3IMAGE_PNG OFF) +option(SDLIMAGE_SAMPLES "Build the SDL3_image sample program(s)" ${SDLIMAGE_SAMPLES_DEFAULT}) +cmake_dependent_option(SDLIMAGE_SAMPLES_INSTALL "Install the SDL3_image sample program(s)" OFF "SDLIMAGE_SAMPLES;SDLIMAGE_INSTALL" OFF) + +option(SDLIMAGE_TESTS "Build unit tests?" OFF) +option(SDLIMAGE_TESTS_INSTALL "Install unit tests?" OFF) + +option(SDLIMAGE_BACKEND_STB "Use stb_image for loading JPEG and PNG files" ON) +cmake_dependent_option(SDLIMAGE_BACKEND_WIC "Add WIC backend (Windows Imaging Component)" OFF WIN32 OFF) +cmake_dependent_option(SDLIMAGE_BACKEND_IMAGEIO "Use native Mac OS X frameworks for loading images" ON APPLE OFF) + +option(SDLIMAGE_AVIF "Support loading AVIF images" ON) +option(SDLIMAGE_BMP "Support loading BMP images" ON) +option(SDLIMAGE_GIF "Support loading GIF images" ON) +option(SDLIMAGE_JPG "Support loading JPEG images" ON) +option(SDLIMAGE_JXL "Support loading JXL images" OFF) +option(SDLIMAGE_LBM "Support loading LBM images" ON) +option(SDLIMAGE_PCX "Support loading PCX images" ON) +option(SDLIMAGE_PNG "Support loading PNG images" ON) +option(SDLIMAGE_PNM "Support loading PNM images" ON) +option(SDLIMAGE_QOI "Support loading QOI images" ON) +option(SDLIMAGE_SVG "Support loading SVG images" ON) +option(SDLIMAGE_TGA "Support loading TGA images" ON) +option(SDLIMAGE_TIF "Support loading TIFF images" ON) +option(SDLIMAGE_WEBP "Support loading WEBP images" ON) +option(SDLIMAGE_XCF "Support loading XCF images" ON) +option(SDLIMAGE_XPM "Support loading XPM images" ON) +option(SDLIMAGE_XV "Support loading XV images" ON) + +cmake_dependent_option(SDLIMAGE_AVIF_SAVE "Add AVIF save support" ON SDLIMAGE_AVIF OFF) +cmake_dependent_option(SDLIMAGE_JPG_SAVE "Add JPEG save support" ON SDLIMAGE_JPG OFF) +cmake_dependent_option(SDLIMAGE_PNG_SAVE "Add PNG save support" ON SDLIMAGE_PNG OFF) set(LIBAVIF_MINIMUM_VERSION "1.0") -if(SDL3IMAGE_VENDORED AND SDL3IMAGE_AVIF) - set(SDL3IMAGE_AVIF_VENDORED ON) +if(SDLIMAGE_VENDORED AND SDLIMAGE_AVIF) + set(SDLIMAGE_AVIF_VENDORED ON) else() - set(SDL3IMAGE_AVIF_VENDORED OFF) + set(SDLIMAGE_AVIF_VENDORED OFF) endif() -cmake_dependent_option(SDL3IMAGE_AVIF_SHARED "Dynamically load AVIF support (requires shared libavif)" - ${SDL3IMAGE_DEPS_SHARED} SDL3IMAGE_AVIF ON) - -if(SDL3IMAGE_AVIF_VENDORED) - set(SDL3IMAGE_DAV1D ON) - set(SDL3IMAGE_DAV1D_VENDORED ON) - set(SDL3IMAGE_AOM ON) - set(SDL3IMAGE_AOM_VENDORED ON) +cmake_dependent_option(SDLIMAGE_AVIF_SHARED "Dynamically load AVIF support (requires shared libavif)" + ${SDLIMAGE_DEPS_SHARED} SDLIMAGE_AVIF ON) + +if(SDLIMAGE_AVIF_VENDORED) + set(SDLIMAGE_DAV1D ON) + set(SDLIMAGE_DAV1D_VENDORED ON) + set(SDLIMAGE_AOM ON) + set(SDLIMAGE_AOM_VENDORED ON) else() - set(SDL3IMAGE_DAV1D OFF) - set(SDL3IMAGE_DAV1D_VENDORED OFF) - set(SDL3IMAGE_AOM OFF) - set(SDL3IMAGE_AOM_VENDORED OFF) + set(SDLIMAGE_DAV1D OFF) + set(SDLIMAGE_DAV1D_VENDORED OFF) + set(SDLIMAGE_AOM OFF) + set(SDLIMAGE_AOM_VENDORED OFF) endif() -if(SDL3IMAGE_AVIF_SHARED) - set(SDL3IMAGE_DAV1D_SHARED ON) - set(SDL3IMAGE_AOM_SHARED ON) +if(SDLIMAGE_AVIF_SHARED) + set(SDLIMAGE_DAV1D_SHARED ON) + set(SDLIMAGE_AOM_SHARED ON) else() - set(SDL3IMAGE_DAV1D_SHARED OFF) - set(SDL3IMAGE_AOM_SHARED OFF) + set(SDLIMAGE_DAV1D_SHARED OFF) + set(SDLIMAGE_AOM_SHARED OFF) endif() -if(SDL3IMAGE_VENDORED AND SDL3IMAGE_JPG AND NOT (SDL3IMAGE_BACKEND_WIC OR SDL3IMAGE_BACKEND_STB OR SDL3IMAGE_BACKEND_IMAGEIO)) - set(SDL3IMAGE_JPG_VENDORED ON) +if(SDLIMAGE_VENDORED AND SDLIMAGE_JPG AND NOT (SDLIMAGE_BACKEND_WIC OR SDLIMAGE_BACKEND_STB OR SDLIMAGE_BACKEND_IMAGEIO)) + set(SDLIMAGE_JPG_VENDORED ON) else() - set(SDL3IMAGE_JPG_VENDORED OFF) + set(SDLIMAGE_JPG_VENDORED OFF) endif() -cmake_dependent_option(SDL3IMAGE_JPG_SHARED "Dynamically load JPG support (requires shared libjpeg)" - ${SDL3IMAGE_DEPS_SHARED} "SDL3IMAGE_JPG;NOT SDL3IMAGE_BACKEND_WIC;NOT SDL3IMAGE_BACKEND_STB;NOT SDL3IMAGE_BACKEND_IMAGEIO" OFF) +cmake_dependent_option(SDLIMAGE_JPG_SHARED "Dynamically load JPG support (requires shared libjpeg)" + ${SDLIMAGE_DEPS_SHARED} "SDLIMAGE_JPG;NOT SDLIMAGE_BACKEND_WIC;NOT SDLIMAGE_BACKEND_STB;NOT SDLIMAGE_BACKEND_IMAGEIO" OFF) -if(SDL3IMAGE_VENDORED AND SDL3IMAGE_JXL) - set(SDL3IMAGE_JXL_VENDORED ON) +if(SDLIMAGE_VENDORED AND SDLIMAGE_JXL) + set(SDLIMAGE_JXL_VENDORED ON) else() - set(SDL3IMAGE_JXL_VENDORED OFF) + set(SDLIMAGE_JXL_VENDORED OFF) endif() -cmake_dependent_option(SDL3IMAGE_JXL_SHARED "Dynamically load JXL support (requires shared libjxl)" - ${SDL3IMAGE_DEPS_SHARED} SDL3IMAGE_JXL OFF) +cmake_dependent_option(SDLIMAGE_JXL_SHARED "Dynamically load JXL support (requires shared libjxl)" + ${SDLIMAGE_DEPS_SHARED} SDLIMAGE_JXL OFF) -if(SDL3IMAGE_VENDORED AND SDL3IMAGE_PNG AND NOT (SDL3IMAGE_BACKEND_WIC OR SDL3IMAGE_BACKEND_STB OR SDL3IMAGE_BACKEND_IMAGEIO)) - set(SDL3IMAGE_PNG_VENDORED ON) +if(SDLIMAGE_VENDORED AND SDLIMAGE_PNG AND NOT (SDLIMAGE_BACKEND_WIC OR SDLIMAGE_BACKEND_STB OR SDLIMAGE_BACKEND_IMAGEIO)) + set(SDLIMAGE_PNG_VENDORED ON) else() - set(SDL3IMAGE_PNG_VENDORED OFF) + set(SDLIMAGE_PNG_VENDORED OFF) endif() -cmake_dependent_option(SDL3IMAGE_PNG_SHARED "Dynamically load PNG support (requires shared libpng)" - ${SDL3IMAGE_DEPS_SHARED} "SDL3IMAGE_PNG;NOT SDL3IMAGE_BACKEND_WIC;NOT SDL3IMAGE_BACKEND_STB;NOT SDL3IMAGE_BACKEND_IMAGEIO" OFF) +cmake_dependent_option(SDLIMAGE_PNG_SHARED "Dynamically load PNG support (requires shared libpng)" + ${SDLIMAGE_DEPS_SHARED} "SDLIMAGE_PNG;NOT SDLIMAGE_BACKEND_WIC;NOT SDLIMAGE_BACKEND_STB;NOT SDLIMAGE_BACKEND_IMAGEIO" OFF) -if(SDL3IMAGE_VENDORED AND SDL3IMAGE_TIF AND NOT (SDL3IMAGE_BACKEND_IMAGEIO OR SDL3IMAGE_BACKEND_WIC)) - set(SDL3IMAGE_TIF_VENDORED ON) +if(SDLIMAGE_VENDORED AND SDLIMAGE_TIF AND NOT (SDLIMAGE_BACKEND_IMAGEIO OR SDLIMAGE_BACKEND_WIC)) + set(SDLIMAGE_TIF_VENDORED ON) else() - set(SDL3IMAGE_TIF_VENDORED OFF) + set(SDLIMAGE_TIF_VENDORED OFF) endif() -cmake_dependent_option(SDL3IMAGE_TIF_SHARED "Dynamically load TIFF support (requires shared libtiff)" - ${SDL3IMAGE_DEPS_SHARED} SDL3IMAGE_TIF OFF) +cmake_dependent_option(SDLIMAGE_TIF_SHARED "Dynamically load TIFF support (requires shared libtiff)" + ${SDLIMAGE_DEPS_SHARED} SDLIMAGE_TIF OFF) -if(SDL3IMAGE_VENDORED AND SDL3IMAGE_WEBP) - set(SDL3IMAGE_WEBP_VENDORED ON) +if(SDLIMAGE_VENDORED AND SDLIMAGE_WEBP) + set(SDLIMAGE_WEBP_VENDORED ON) else() - set(SDL3IMAGE_WEBP_VENDORED OFF) + set(SDLIMAGE_WEBP_VENDORED OFF) endif() -cmake_dependent_option(SDL3IMAGE_WEBP_SHARED "Dynamically load WEBP support (requires shared libwebp)" - ${SDL3IMAGE_DEPS_SHARED} SDL3IMAGE_WEBP OFF) +cmake_dependent_option(SDLIMAGE_WEBP_SHARED "Dynamically load WEBP support (requires shared libwebp)" + ${SDLIMAGE_DEPS_SHARED} SDLIMAGE_WEBP OFF) -if(SDL3IMAGE_PNG_VENDORED) - set(SDL3IMAGE_ZLIB ON) +if(SDLIMAGE_PNG_VENDORED) + set(SDLIMAGE_ZLIB ON) else() - set(SDL3IMAGE_ZLIB OFF) + set(SDLIMAGE_ZLIB OFF) endif() -if(SDL3IMAGE_VENDORED AND SDL3IMAGE_PNG_VENDORED) - set(SDL3IMAGE_ZLIB_VENDORED ON) +if(SDLIMAGE_VENDORED AND SDLIMAGE_PNG_VENDORED) + set(SDLIMAGE_ZLIB_VENDORED ON) else() - set(SDL3IMAGE_ZLIB_VENDORED OFF) + set(SDLIMAGE_ZLIB_VENDORED OFF) endif() -if(SDL3IMAGE_PNG_SHARED) - set(SDL3IMAGE_ZLIB_SHARED ON) +if(SDLIMAGE_PNG_SHARED) + set(SDLIMAGE_ZLIB_SHARED ON) else() - set(SDL3IMAGE_ZLIB_SHARED OFF) + set(SDLIMAGE_ZLIB_SHARED OFF) endif() # Save BUILD_SHARED_LIBS variable -set(SDL3IMAGE_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) +set(SDLIMAGE_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) set(sdl_required_components Headers) -if(SDL3IMAGE_BUILD_SHARED_LIBS) +if(SDLIMAGE_BUILD_SHARED_LIBS) set(sdl3_image_target_name SDL3_image-shared) set(sdl3_target_name SDL3::SDL3-shared) @@ -234,7 +234,7 @@ if(NOT DEFINED OpenGL_GL_PREFERENCE) set(OpenGL_GL_PREFERENCE GLVND) endif() -set(BUILD_SHARED_LIBS ${SDL3IMAGE_BUILD_SHARED_LIBS}) +set(BUILD_SHARED_LIBS ${SDLIMAGE_BUILD_SHARED_LIBS}) add_library(${sdl3_image_target_name} src/IMG.c src/IMG_WIC.c @@ -273,11 +273,11 @@ target_compile_definitions(${sdl3_image_target_name} PRIVATE SDL_BUILD_MICRO_VERSION=${MICRO_VERSION} ) target_link_libraries(${sdl3_image_target_name} PUBLIC SDL3::Headers) -if(SDL3IMAGE_BUILD_SHARED_LIBS) +if(SDLIMAGE_BUILD_SHARED_LIBS) target_link_libraries(${sdl3_image_target_name} PRIVATE SDL3::SDL3-shared) endif() -sdl_add_warning_options(${sdl3_image_target_name} WARNING_AS_ERROR ${SDL3IMAGE_WERROR}) -if(WIN32 AND SDL3IMAGE_BUILD_SHARED_LIBS) +sdl_add_warning_options(${sdl3_image_target_name} WARNING_AS_ERROR ${SDLIMAGE_WERROR}) +if(WIN32 AND SDLIMAGE_BUILD_SHARED_LIBS) target_sources(${sdl3_image_target_name} PRIVATE src/version.rc ) @@ -320,7 +320,7 @@ if(NOT ANDROID) sdl_no_deprecated_errors(${sdl3_image_target_name}) endif() endif() -if(SDL3IMAGE_BUILD_SHARED_LIBS) +if(SDLIMAGE_BUILD_SHARED_LIBS) if(WIN32) set_target_properties(${sdl3_image_target_name} PROPERTIES PREFIX "" @@ -336,16 +336,16 @@ else() endif() # Use `Compatible Interface Properties` to ensure a shared SDL3_image is built with a shared SDL3 -if(SDL3IMAGE_BUILD_SHARED_LIBS) +if(SDLIMAGE_BUILD_SHARED_LIBS) set_property(TARGET ${sdl3_image_target_name} PROPERTY INTERFACE_SDL3_SHARED TRUE) set_property(TARGET ${sdl3_image_target_name} APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL3_SHARED) endif() -if(SDL3IMAGE_BUILD_SHARED_LIBS) +if(SDLIMAGE_BUILD_SHARED_LIBS) sdl_target_link_options_no_undefined(${sdl3_image_target_name}) endif() -if(SDL3IMAGE_BUILD_SHARED_LIBS) +if(SDLIMAGE_BUILD_SHARED_LIBS) # Make sure static library dependencies are built with -fPIC when building a shared SDL3_image set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() @@ -354,30 +354,30 @@ set(INSTALL_EXTRA_TARGETS) set(INSTALL_EXTRA_CMAKE_MODULES) set(PC_LIBS) set(PC_REQUIRES) -set(SDL3IMAGE_BACKENDS) +set(SDLIMAGE_BACKENDS) -list(APPEND SDL3IMAGE_BACKENDS STB) -set(SDL3IMAGE_STB_ENABLED FALSE) -if(SDL3IMAGE_BACKEND_STB) - set(SDL3IMAGE_STB_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS STB) +set(SDLIMAGE_STB_ENABLED FALSE) +if(SDLIMAGE_BACKEND_STB) + set(SDLIMAGE_STB_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE USE_STBIMAGE) endif() -list(APPEND SDL3IMAGE_BACKENDS IMAGEIO) -set(SDL3IMAGE_IMAGEIO_ENABLED FALSE) +list(APPEND SDLIMAGE_BACKENDS IMAGEIO) +set(SDLIMAGE_IMAGEIO_ENABLED FALSE) if(APPLE) - if(SDL3IMAGE_BACKEND_IMAGEIO) - set(SDL3IMAGE_IMAGEIO_ENABLED TRUE) + if(SDLIMAGE_BACKEND_IMAGEIO) + set(SDLIMAGE_IMAGEIO_ENABLED TRUE) target_link_libraries(${sdl3_image_target_name} PRIVATE -Wl,-framework,ApplicationServices) target_link_libraries(${sdl3_image_target_name} PRIVATE objc) target_sources(${sdl3_image_target_name} PRIVATE src/IMG_ImageIO.m ) - if (SDL3IMAGE_PNG AND NOT SDL3IMAGE_BACKEND_STB) + if (SDLIMAGE_PNG AND NOT SDLIMAGE_BACKEND_STB) target_compile_definitions(${sdl3_image_target_name} PRIVATE PNG_USES_IMAGEIO) endif() - if (SDL3IMAGE_JPG AND NOT SDL3IMAGE_BACKEND_STB) + if (SDLIMAGE_JPG AND NOT SDLIMAGE_BACKEND_STB) target_compile_definitions(${sdl3_image_target_name} PRIVATE JPG_USES_IMAGEIO) endif() else() @@ -385,26 +385,26 @@ if(APPLE) endif() endif() -list(APPEND SDL3IMAGE_BACKENDS WIC) -set(SDL3IMAGE_WIC_ENABLED FALSE) -if(SDL3IMAGE_BACKEND_WIC) - set(SDL3IMAGE_WIC_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS WIC) +set(SDLIMAGE_WIC_ENABLED FALSE) +if(SDLIMAGE_BACKEND_WIC) + set(SDLIMAGE_WIC_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE SDL_IMAGE_USE_WIC_BACKEND) endif() -if(SDL3IMAGE_ZLIB) - if(SDL3IMAGE_ZLIB_VENDORED) +if(SDLIMAGE_ZLIB) + if(SDLIMAGE_ZLIB_VENDORED) message(STATUS "${PROJECT_NAME}: Using vendored zlib") # disable build of zlib example programs: set(ZLIB_BUILD_EXAMPLES OFF CACHE BOOL "zlib examples" FORCE) - sdl_check_project_in_subfolder(external/zlib zlib SDL3IMAGE_VENDORED) + sdl_check_project_in_subfolder(external/zlib zlib SDLIMAGE_VENDORED) add_subdirectory(external/zlib EXCLUDE_FROM_ALL) # PNG_BUILD_ZLIB variable is used by vendored libpng set(PNG_BUILD_ZLIB ON CACHE BOOL "libpng option to tell it should use 'our' vendored ZLIB library" FORCE) # ZLIB_INCLUDE_DIR variable is used by vendored libpng set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/zlib;${CMAKE_CURRENT_BINARY_DIR}/external/zlib" CACHE STRING "path of zlib, passed to libpng" FORCE) # ZLIB_LIBRARY variable is used by vendored libpng - if(SDL3IMAGE_ZLIB_SHARED) + if(SDLIMAGE_ZLIB_SHARED) set(ZLIB_LIBRARY zlib) else() set(ZLIB_LIBRARY zlibstatic) @@ -417,7 +417,7 @@ if(SDL3IMAGE_ZLIB) # ZLIB_INCLUDE_DIRS variable is used by vendored libpng set(ZLIB_INCLUDE_DIRS "${ZLIB_INCLUDE_DIR}") target_include_directories(${ZLIB_LIBRARY} INTERFACE $) - if(SDL3IMAGE_ZLIB_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS) + if(SDLIMAGE_ZLIB_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS) list(APPEND INSTALL_EXTRA_TARGETS ${ZLIB_LIBRARY}) endif() set_target_properties(${ZLIB_LIBRARY} PROPERTIES EXPORT_NAME external_zlib) @@ -427,16 +427,16 @@ if(SDL3IMAGE_ZLIB) endif() endif() -if(SDL3IMAGE_DAV1D) - if(SDL3IMAGE_DAV1D_VENDORED) +if(SDLIMAGE_DAV1D) + if(SDLIMAGE_DAV1D_VENDORED) message(STATUS "${PROJECT_NAME}: Using vendored dav1d") - set(BUILD_SHARED_LIBS ${SDL3IMAGE_DAV1D_SHARED}) + set(BUILD_SHARED_LIBS ${SDLIMAGE_DAV1D_SHARED}) add_subdirectory(external/dav1d EXCLUDE_FROM_ALL) if(DAV1D_ASM AND (CHECK_CPU_ARCHITECTURE_X64 OR CHECK_CPU_ARCHITECTURE_X86)) enable_language(ASM_NASM) endif() set(DAV1D_LIBRARY dav1d) - if(SDL3IMAGE_DAV1D_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS) + if(SDLIMAGE_DAV1D_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS) list(APPEND INSTALL_EXTRA_TARGETS dav1d) endif() else() @@ -444,16 +444,16 @@ if(SDL3IMAGE_DAV1D) endif() endif() -if(SDL3IMAGE_AOM) - if(SDL3IMAGE_AOM_VENDORED) +if(SDLIMAGE_AOM) + if(SDLIMAGE_AOM_VENDORED) message(STATUS "${PROJECT_NAME}: Using vendored aom") - set(BUILD_SHARED_LIBS ${SDL3IMAGE_AOM_SHARED}) + set(BUILD_SHARED_LIBS ${SDLIMAGE_AOM_SHARED}) set(ENABLE_DOCS OFF CACHE BOOL "") set(ENABLE_EXAMPLES OFF CACHE BOOL "") set(ENABLE_TESTDATA OFF CACHE BOOL "") set(ENABLE_TESTS OFF CACHE BOOL "") set(ENABLE_TOOLS OFF CACHE BOOL "") - if(SDL3IMAGE_AOM_SHARED) + if(SDLIMAGE_AOM_SHARED) set(CONFIG_AV1_DECODER 1 CACHE BOOL "" FORCE) else() set(CONFIG_AV1_DECODER 0 CACHE BOOL "" FORCE) @@ -471,7 +471,7 @@ if(SDL3IMAGE_AOM) endif() add_subdirectory(external/aom EXCLUDE_FROM_ALL) set(AOM_LIBRARY aom) - if(SDL3IMAGE_AOM_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS) + if(SDLIMAGE_AOM_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS) list(APPEND INSTALL_EXTRA_TARGETS aom) endif() else() @@ -479,31 +479,31 @@ if(SDL3IMAGE_AOM) endif() endif() -list(APPEND SDL3IMAGE_BACKENDS AVIF) -set(SDL3IMAGE_AVIF_ENABLED FALSE) -if(SDL3IMAGE_AVIF) - if(SDL3IMAGE_AVIF_VENDORED) - set(SDL3IMAGE_AVIF_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS AVIF) +set(SDLIMAGE_AVIF_ENABLED FALSE) +if(SDLIMAGE_AVIF) + if(SDLIMAGE_AVIF_VENDORED) + set(SDLIMAGE_AVIF_ENABLED TRUE) message(STATUS "${PROJECT_NAME}: Using vendored libavif") - sdl_check_project_in_subfolder(external/libavif libavif SDL3IMAGE_VENDORED) + sdl_check_project_in_subfolder(external/libavif libavif SDLIMAGE_VENDORED) set(SKIP_INSTALL_LIBRARIES TRUE) - set(BUILD_SHARED_LIBS ${SDL3IMAGE_AVIF_SHARED}) + set(BUILD_SHARED_LIBS ${SDLIMAGE_AVIF_SHARED}) set(AVIF_CODEC_DAV1D ON CACHE BOOL "Use dav1d codec for decoding" FORCE) set(AVIF_LOCAL_DAV1D OFF CACHE BOOL "Build dav1d by libavif" FORCE) set(AVIF_CODEC_AOM ON CACHE BOOL "Use aom codec for decoding" FORCE) set(AVIF_LOCAL_AOM OFF CACHE BOOL "Build aom by libavif" FORCE) set(AVIF_CODEC_AOM_ENCODE ON CACHE BOOL "Enable aom encoder" FORCE) set(AVIF_CODEC_AOM_DECODE OFF CACHE BOOL "Enable aom decoder" FORCE) - set(LIBAVIF_WITH_SHARPYUV_SDLIMAGE ${SDL3IMAGE_WEBP} CACHE BOOL "Build libavif with sharpyuv support (re-use sharpyuv built by libwebp)" FORCE) - set(BUILD_SHARED_LIBS ${SDL3IMAGE_AVIF_SHARED}) + set(LIBAVIF_WITH_SHARPYUV_SDLIMAGE ${SDLIMAGE_WEBP} CACHE BOOL "Build libavif with sharpyuv support (re-use sharpyuv built by libwebp)" FORCE) + set(BUILD_SHARED_LIBS ${SDLIMAGE_AVIF_SHARED}) set(AOM_LIBRARIES "aom" CACHE STRING "aom libraries" FORCE) add_subdirectory(external/libavif EXCLUDE_FROM_ALL) - if(SDL3IMAGE_AVIF_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS) + if(SDLIMAGE_AVIF_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS) list(APPEND INSTALL_EXTRA_TARGETS avif) endif() set_target_properties(avif PROPERTIES EXPORT_NAME external_libavif) add_library(SDL3_image::external_libavif ALIAS avif) - if(NOT SDL3IMAGE_AVIF_SHARED) + if(NOT SDLIMAGE_AVIF_SHARED) list(APPEND PC_LIBS -l$) endif() if(NOT MSVC) @@ -516,8 +516,8 @@ if(SDL3IMAGE_AVIF) find_package(libavif "${LIBAVIF_MINIMUM_VERSION}" QUIET ${required}) if(libavif_FOUND) message(STATUS "${PROJECT_NAME}: Using system libavif") - set(SDL3IMAGE_AVIF_ENABLED TRUE) - if(NOT SDL3IMAGE_AVIF_SHARED) + set(SDLIMAGE_AVIF_ENABLED TRUE) + if(NOT SDLIMAGE_AVIF_SHARED) list(APPEND PC_REQUIRES "libavif >= ${LIBAVIF_MINIMUM_VERSION}") endif() else() @@ -525,12 +525,12 @@ if(SDL3IMAGE_AVIF) message(${fatal_error} "libavif NOT found") endif() endif() - if(SDL3IMAGE_AVIF_ENABLED) + if(SDLIMAGE_AVIF_ENABLED) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_AVIF - SDL_IMAGE_SAVE_AVIF=$ + SDL_IMAGE_SAVE_AVIF=$ ) - if(SDL3IMAGE_AVIF_SHARED) + if(SDLIMAGE_AVIF_SHARED) target_include_directories(${sdl3_image_target_name} PRIVATE $ $ @@ -539,7 +539,7 @@ if(SDL3IMAGE_AVIF) target_get_dynamic_library(dynamic_avif avif) message(STATUS "Dynamic libavif: ${dynamic_avif}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_AVIF_DYNAMIC=\"${dynamic_avif}\"") - if(SDL3IMAGE_AVIF_VENDORED) + if(SDLIMAGE_AVIF_VENDORED) add_dependencies(${sdl3_image_target_name} avif) endif() else() @@ -548,54 +548,54 @@ if(SDL3IMAGE_AVIF) endif() endif() -list(APPEND SDL3IMAGE_BACKENDS BMP) -set(SDL3IMAGE_BMP_ENABLED FALSE) -if(SDL3IMAGE_BMP) - set(SDL3IMAGE_BMP_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS BMP) +set(SDLIMAGE_BMP_ENABLED FALSE) +if(SDLIMAGE_BMP) + set(SDLIMAGE_BMP_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_BMP) endif() -list(APPEND SDL3IMAGE_BACKENDS GIF) -set(SDL3IMAGE_GIF_ENABLED FALSE) -if(SDL3IMAGE_GIF) - set(SDL3IMAGE_GIF_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS GIF) +set(SDLIMAGE_GIF_ENABLED FALSE) +if(SDLIMAGE_GIF) + set(SDLIMAGE_GIF_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_GIF) endif() -list(APPEND SDL3IMAGE_BACKENDS JPG) -set(SDL3IMAGE_JPG_ENABLED FALSE) -if(SDL3IMAGE_JPG) - if(SDL3IMAGE_BACKEND_STB OR SDL3IMAGE_BACKEND_WIC OR SDL3IMAGE_BACKEND_IMAGEIO) - set(SDL3IMAGE_JPG_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS JPG) +set(SDLIMAGE_JPG_ENABLED FALSE) +if(SDLIMAGE_JPG) + if(SDLIMAGE_BACKEND_STB OR SDLIMAGE_BACKEND_WIC OR SDLIMAGE_BACKEND_IMAGEIO) + set(SDLIMAGE_JPG_ENABLED TRUE) else() - if(SDL3IMAGE_JPG_VENDORED) - set(SDL3IMAGE_JPG_ENABLED TRUE) + if(SDLIMAGE_JPG_VENDORED) + set(SDLIMAGE_JPG_ENABLED TRUE) message(STATUS "${PROJECT_NAME}: Using vendored libjpeg") - sdl_check_project_in_subfolder(external/jpeg libjpeg SDL3IMAGE_VENDORED) - set(BUILD_SHARED_LIBS ${SDL3IMAGE_JPG_SHARED}) + sdl_check_project_in_subfolder(external/jpeg libjpeg SDLIMAGE_VENDORED) + set(BUILD_SHARED_LIBS ${SDLIMAGE_JPG_SHARED}) add_subdirectory(external/jpeg EXCLUDE_FROM_ALL) - if(SDL3IMAGE_JPG_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS) + if(SDLIMAGE_JPG_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS) list(APPEND INSTALL_EXTRA_TARGETS jpeg) endif() set_target_properties(jpeg PROPERTIES EXPORT_NAME external_libjpeg) add_library(SDL3_image::external_libjpeg ALIAS jpeg) - if(NOT SDL3IMAGE_JPG_SHARED) + if(NOT SDLIMAGE_JPG_SHARED) list(APPEND PC_LIBS -l$) endif() else() find_package(JPEG ${required}) if(JPEG_FOUND) message(STATUS "${PROJECT_NAME}: Using system libjpeg") - set(SDL3IMAGE_JPG_ENABLED TRUE) - if(NOT SDL3IMAGE_JPG_SHARED) + set(SDLIMAGE_JPG_ENABLED TRUE) + if(NOT SDLIMAGE_JPG_SHARED) list(APPEND PC_REQUIRES libjpeg) endif() else() message(${fatal_error} "libjpeg NOT found") endif() endif() - if(SDL3IMAGE_JPG_ENABLED) - if(SDL3IMAGE_JPG_SHARED) + if(SDLIMAGE_JPG_ENABLED) + if(SDLIMAGE_JPG_SHARED) target_include_directories(${sdl3_image_target_name} PRIVATE $ $ @@ -604,7 +604,7 @@ if(SDL3IMAGE_JPG) target_get_dynamic_library(dynamic_jpeg JPEG::JPEG) message(STATUS "Dynamic libjpeg: ${dynamic_jpeg}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_JPG_DYNAMIC=\"${dynamic_jpeg}\"") - if(SDL3IMAGE_JPG_VENDORED) + if(SDLIMAGE_JPG_VENDORED) add_dependencies(${sdl3_image_target_name} JPEG::JPEG) endif() else() @@ -612,19 +612,19 @@ if(SDL3IMAGE_JPG) endif() endif() endif() - if(SDL3IMAGE_JPG_ENABLED) + if(SDLIMAGE_JPG_ENABLED) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_JPG - SDL_IMAGE_SAVE_JPG=$ + SDL_IMAGE_SAVE_JPG=$ ) endif() endif() -list(APPEND SDL3IMAGE_BACKENDS JXL) -set(SDL3IMAGE_JXL_ENABLED FALSE) -if(SDL3IMAGE_JXL) - if(SDL3IMAGE_JXL_VENDORED) - set(SDL3IMAGE_JXL_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS JXL) +set(SDLIMAGE_JXL_ENABLED FALSE) +if(SDLIMAGE_JXL) + if(SDLIMAGE_JXL_VENDORED) + set(SDLIMAGE_JXL_ENABLED TRUE) enable_language(CXX) message(STATUS "${PROJECT_NAME}: Using vendored libjxl") # BUILD_TESTING variable is used by libjxl @@ -641,10 +641,10 @@ if(SDL3IMAGE_JXL) set(JPEGXL_ENABLE_SKCMS OFF CACHE BOOL "libjxl skcms option" FORCE) # JPEGXL_FORCE_SYSTEM_HWY variable is used by libjxl set(JPEGXL_FORCE_SYSTEM_HWY OFF CACHE BOOL "libjxl highway option" FORCE) - sdl_check_project_in_subfolder(external/libjxl libjxl SDL3IMAGE_VENDORED) - set(BUILD_SHARED_LIBS ${SDL3IMAGE_JXL_SHARED}) + sdl_check_project_in_subfolder(external/libjxl libjxl SDLIMAGE_VENDORED) + set(BUILD_SHARED_LIBS ${SDLIMAGE_JXL_SHARED}) add_subdirectory(external/libjxl EXCLUDE_FROM_ALL) - if(SDL3IMAGE_JXL_SHARED) + if(SDLIMAGE_JXL_SHARED) set(jxl_lib jxl) set(jxl_install_libs brotlidec brotlicommon brotlienc jxl) else() @@ -655,7 +655,7 @@ if(SDL3IMAGE_JXL) -l$ -l$ ) endif() - if(SDL3IMAGE_JXL_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS) + if(SDLIMAGE_JXL_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS) list(APPEND INSTALL_EXTRA_TARGETS ${jxl_install_libs}) endif() set_target_properties(${jxl_lib} PROPERTIES EXPORT_NAME external_libjxl) @@ -667,8 +667,8 @@ if(SDL3IMAGE_JXL) find_package(libjxl ${required}) if(libjxl_FOUND) message(STATUS "${PROJECT_NAME}: Using system libjxl") - set(SDL3IMAGE_JXL_ENABLED TRUE) - if(NOT SDL3IMAGE_JXL_SHARED) + set(SDLIMAGE_JXL_ENABLED TRUE) + if(NOT SDLIMAGE_JXL_SHARED) list(APPEND PC_REQUIRES libjxl) list(APPEND INSTALL_EXTRA_CMAKE_MODULES cmake/Findlibjxl.cmake) endif() @@ -676,9 +676,9 @@ if(SDL3IMAGE_JXL) message(${fatal_error} "libjxl NOT found") endif() endif() - if(SDL3IMAGE_JXL_ENABLED) + if(SDLIMAGE_JXL_ENABLED) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_JXL) - if(SDL3IMAGE_JXL_SHARED) + if(SDLIMAGE_JXL_SHARED) target_include_directories(${sdl3_image_target_name} PRIVATE $ $ @@ -687,7 +687,7 @@ if(SDL3IMAGE_JXL) target_get_dynamic_library(dynamic_jxl libjxl::libjxl) message(STATUS "Dynamic libjxl: ${dynamic_jxl}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_JXL_DYNAMIC=\"${dynamic_jxl}\"") - if(SDL3IMAGE_JXL_VENDORED) + if(SDLIMAGE_JXL_VENDORED) add_dependencies(${sdl3_image_target_name} libjxl::libjxl) endif() else() @@ -696,34 +696,34 @@ if(SDL3IMAGE_JXL) endif() endif() -list(APPEND SDL3IMAGE_BACKENDS LBM) -set(SDL3IMAGE_LBM_ENABLED FALSE) -if(SDL3IMAGE_LBM) - set(SDL3IMAGE_LBM_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS LBM) +set(SDLIMAGE_LBM_ENABLED FALSE) +if(SDLIMAGE_LBM) + set(SDLIMAGE_LBM_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_LBM) endif() -list(APPEND SDL3IMAGE_BACKENDS PCX) -set(SDL3IMAGE_PCX_ENABLED FALSE) -if(SDL3IMAGE_PCX) - set(SDL3IMAGE_PCX_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS PCX) +set(SDLIMAGE_PCX_ENABLED FALSE) +if(SDLIMAGE_PCX) + set(SDLIMAGE_PCX_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_PCX) endif() -list(APPEND SDL3IMAGE_BACKENDS PNG) -set(SDL3IMAGE_PNG_ENABLED FALSE) -if(SDL3IMAGE_PNG) - if(SDL3IMAGE_BACKEND_STB OR SDL3IMAGE_BACKEND_WIC OR SDL3IMAGE_BACKEND_IMAGEIO) - set(SDL3IMAGE_PNG_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS PNG) +set(SDLIMAGE_PNG_ENABLED FALSE) +if(SDLIMAGE_PNG) + if(SDLIMAGE_BACKEND_STB OR SDLIMAGE_BACKEND_WIC OR SDLIMAGE_BACKEND_IMAGEIO) + set(SDLIMAGE_PNG_ENABLED TRUE) else() - if(SDL3IMAGE_PNG_VENDORED) - set(SDL3IMAGE_PNG_ENABLED TRUE) + if(SDLIMAGE_PNG_VENDORED) + set(SDLIMAGE_PNG_ENABLED TRUE) message(STATUS "${PROJECT_NAME}: Using vendored libpng") set(PNG_TESTS OFF CACHE BOOL "Build PNG Tests" FORCE) set(SKIP_INSTALL_EXPORT TRUE) - sdl_check_project_in_subfolder(external/libpng libpng SDL3IMAGE_VENDORED) + sdl_check_project_in_subfolder(external/libpng libpng SDLIMAGE_VENDORED) add_subdirectory(external/libpng EXCLUDE_FROM_ALL) - if(SDL3IMAGE_PNG_SHARED) + if(SDLIMAGE_PNG_SHARED) set(PNG_LIBRARY png_shared) else() set(PNG_LIBRARY png_static) @@ -731,14 +731,14 @@ if(SDL3IMAGE_PNG) add_library(PNG::PNG ALIAS ${PNG_LIBRARY}) set_property(TARGET ${PNG_LIBRARY} PROPERTY DEBUG_POSTFIX "") target_include_directories(${sdl3_image_target_name} PRIVATE external/libpng) - if(SDL3IMAGE_PNG_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS) + if(SDLIMAGE_PNG_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS) list(APPEND INSTALL_EXTRA_TARGETS ${PNG_LIBRARY}) endif() set_target_properties(${PNG_LIBRARY} PROPERTIES EXPORT_NAME external_libpng) add_library(SDL3_image::external_libpng ALIAS ${PNG_LIBRARY}) - if(NOT SDL3IMAGE_PNG_SHARED) + if(NOT SDLIMAGE_PNG_SHARED) list(APPEND PC_LIBS -l$) - if(SDL3IMAGE_ZLIB_VENDORED) + if(SDLIMAGE_ZLIB_VENDORED) list(APPEND PC_LIBS -l$) else() list(APPEND PC_REQUIRES zlib) @@ -748,16 +748,16 @@ if(SDL3IMAGE_PNG) find_package(PNG ${required}) if(PNG_FOUND) message(STATUS "${PROJECT_NAME}: Using system libpng") - set(SDL3IMAGE_PNG_ENABLED TRUE) - if(NOT SDL3IMAGE_PNG_SHARED) + set(SDLIMAGE_PNG_ENABLED TRUE) + if(NOT SDLIMAGE_PNG_SHARED) list(APPEND PC_REQUIRES libpng) endif() else() message(${FATAL_ERROR} "libpng NOT found") endif() endif() - if(SDL3IMAGE_PNG_ENABLED) - if(SDL3IMAGE_PNG_SHARED) + if(SDLIMAGE_PNG_ENABLED) + if(SDLIMAGE_PNG_SHARED) target_include_directories(${sdl3_image_target_name} PRIVATE $ $ @@ -766,7 +766,7 @@ if(SDL3IMAGE_PNG) target_get_dynamic_library(dynamic_png PNG::PNG) message(STATUS "Dynamic libpng: ${dynamic_png}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_PNG_DYNAMIC=\"${dynamic_png}\"") - if(SDL3IMAGE_PNG_VENDORED) + if(SDLIMAGE_PNG_VENDORED) add_dependencies(${sdl3_image_target_name} PNG::PNG) endif() else() @@ -774,50 +774,50 @@ if(SDL3IMAGE_PNG) endif() endif() endif() - if(SDL3IMAGE_PNG_ENABLED) + if(SDLIMAGE_PNG_ENABLED) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_PNG - SDL_IMAGE_SAVE_PNG=$ + SDL_IMAGE_SAVE_PNG=$ ) endif() endif() -list(APPEND SDL3IMAGE_BACKENDS PNM) -set(SDL3IMAGE_PNM_ENABLED FALSE) -if(SDL3IMAGE_PNM) - set(SDL3IMAGE_PNM_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS PNM) +set(SDLIMAGE_PNM_ENABLED FALSE) +if(SDLIMAGE_PNM) + set(SDLIMAGE_PNM_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_PNM) endif() -list(APPEND SDL3IMAGE_BACKENDS QOI) -set(SDL3IMAGE_QOI_ENABLED FALSE) -if(SDL3IMAGE_QOI) - set(SDL3IMAGE_QOI_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS QOI) +set(SDLIMAGE_QOI_ENABLED FALSE) +if(SDLIMAGE_QOI) + set(SDLIMAGE_QOI_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_QOI) endif() -list(APPEND SDL3IMAGE_BACKENDS SVG) -set(SDL3IMAGE_SVG_ENABLED FALSE) -if(SDL3IMAGE_SVG) - set(SDL3IMAGE_SVG_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS SVG) +set(SDLIMAGE_SVG_ENABLED FALSE) +if(SDLIMAGE_SVG) + set(SDLIMAGE_SVG_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_SVG) endif() -list(APPEND SDL3IMAGE_BACKENDS TGA) -set(SDL3IMAGE_TGA_ENABLED FALSE) -if(SDL3IMAGE_TGA) - set(SDL3IMAGE_TGA_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS TGA) +set(SDLIMAGE_TGA_ENABLED FALSE) +if(SDLIMAGE_TGA) + set(SDLIMAGE_TGA_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_TGA) endif() -list(APPEND SDL3IMAGE_BACKENDS TIF) -set(SDL3IMAGE_TIF_ENABLED FALSE) -if(SDL3IMAGE_TIF) - if(SDL3IMAGE_BACKEND_IMAGEIO OR SDL3IMAGE_BACKEND_WIC) - set(SDL3IMAGE_TIF_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS TIF) +set(SDLIMAGE_TIF_ENABLED FALSE) +if(SDLIMAGE_TIF) + if(SDLIMAGE_BACKEND_IMAGEIO OR SDLIMAGE_BACKEND_WIC) + set(SDLIMAGE_TIF_ENABLED TRUE) else() - if(SDL3IMAGE_TIF_VENDORED) - set(SDL3IMAGE_TIF_ENABLED TRUE) + if(SDLIMAGE_TIF_VENDORED) + set(SDLIMAGE_TIF_ENABLED TRUE) message(STATUS "${PROJECT_NAME}: Using vendored libtiff") # tiff-tests variable is used by vendored libtiff set(tiff-tests OFF CACHE BOOL "libtiff: tests" FORCE) @@ -841,25 +841,25 @@ if(SDL3IMAGE_TIF) set(ZSTD_FOUND OFF) # WEBP_LIBRARY variable is used by vendored libtiff set(WEBP_LIBRARY "") - sdl_check_project_in_subfolder(external/libtiff libtiff SDL3IMAGE_VENDORED) - set(BUILD_SHARED_LIBS ${SDL3IMAGE_TIF_SHARED}) + sdl_check_project_in_subfolder(external/libtiff libtiff SDLIMAGE_VENDORED) + set(BUILD_SHARED_LIBS ${SDLIMAGE_TIF_SHARED}) add_subdirectory(external/libtiff EXCLUDE_FROM_ALL) add_library(TIFF::TIFF ALIAS tiff) set(SDL2IMAGE_TIF_TARGET "TIFF::tiff") - if(SDL3IMAGE_TIF_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS) + if(SDLIMAGE_TIF_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS) list(APPEND INSTALL_EXTRA_TARGETS tiff) endif() set_target_properties(tiff PROPERTIES EXPORT_NAME external_libtiff) add_library(SDL3_image::external_libtiff ALIAS tiff) - if(NOT SDL3IMAGE_TIF_SHARED) + if(NOT SDLIMAGE_TIF_SHARED) list(APPEND PC_LIBS -l$) endif() else() find_package(TIFF ${required}) if(TIFF_FOUND) message(STATUS "${PROJECT_NAME}: Using system libtiff") - set(SDL3IMAGE_TIF_ENABLED TRUE) - if(NOT SDL3IMAGE_TIF_SHARED) + set(SDLIMAGE_TIF_ENABLED TRUE) + if(NOT SDLIMAGE_TIF_SHARED) list(APPEND PC_REQUIRES libtiff-4) endif() if(TARGET TIFF::tiff) @@ -873,9 +873,9 @@ if(SDL3IMAGE_TIF) message(${fatal_error} "libtiff NOT found") endif() endif() - if(SDL3IMAGE_TIF_ENABLED) + if(SDLIMAGE_TIF_ENABLED) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_TIF) - if(SDL3IMAGE_TIF_SHARED) + if(SDLIMAGE_TIF_SHARED) target_include_directories(${sdl3_image_target_name} PRIVATE $ $ @@ -884,7 +884,7 @@ if(SDL3IMAGE_TIF) target_get_dynamic_library(dynamic_tif ${SDL2IMAGE_TIF_TARGET}) message(STATUS "Dynamic libtiff: ${dynamic_tif}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_TIF_DYNAMIC=\"${dynamic_tif}\"") - if(SDL3IMAGE_TIF_VENDORED) + if(SDLIMAGE_TIF_VENDORED) add_dependencies(${sdl3_image_target_name} ${SDL2IMAGE_TIF_TARGET}) endif() else() @@ -894,22 +894,22 @@ if(SDL3IMAGE_TIF) endif() endif() -list(APPEND SDL3IMAGE_BACKENDS WEBP) -set(SDL3IMAGE_WEBP_ENABLED FALSE) -if(SDL3IMAGE_WEBP) +list(APPEND SDLIMAGE_BACKENDS WEBP) +set(SDLIMAGE_WEBP_ENABLED FALSE) +if(SDLIMAGE_WEBP) # missing cpufeatures - if(SDL3IMAGE_WEBP_VENDORED) - set(SDL3IMAGE_WEBP_ENABLED TRUE) + if(SDLIMAGE_WEBP_VENDORED) + set(SDLIMAGE_WEBP_ENABLED TRUE) message(STATUS "${PROJECT_NAME}: Using vendored libwebp") - sdl_check_project_in_subfolder(external/libwebp libwebp SDL3IMAGE_VENDORED) - set(BUILD_SHARED_LIBS ${SDL3IMAGE_WEBP_SHARED}) + sdl_check_project_in_subfolder(external/libwebp libwebp SDLIMAGE_VENDORED) + set(BUILD_SHARED_LIBS ${SDLIMAGE_WEBP_SHARED}) add_subdirectory(external/libwebp EXCLUDE_FROM_ALL) target_include_directories(${sdl3_image_target_name} PRIVATE external/libwebp/src) add_library(WebP::webp ALIAS webp) add_library(WebP::webpdemux ALIAS webpdemux) - if(SDL3IMAGE_WEBP_SHARED OR NOT SDL3IMAGE_BUILD_SHARED_LIBS) + if(SDLIMAGE_WEBP_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS) list(APPEND INSTALL_EXTRA_TARGETS webp webpdemux) - if(NOT SDL3IMAGE_WEBP_SHARED) + if(NOT SDLIMAGE_WEBP_SHARED) list(APPEND INSTALL_EXTRA_TARGETS sharpyuv) endif() endif() @@ -921,8 +921,8 @@ if(SDL3IMAGE_WEBP) find_package(webp ${required}) if(webp_FOUND) message(STATUS "${PROJECT_NAME}: Using system libwebp") - set(SDL3IMAGE_WEBP_ENABLED TRUE) - if(NOT SDL3IMAGE_WEBP_SHARED) + set(SDLIMAGE_WEBP_ENABLED TRUE) + if(NOT SDLIMAGE_WEBP_SHARED) list(APPEND PC_REQUIRES libwebp) list(APPEND INSTALL_EXTRA_CMAKE_MODULES cmake/Findwebp.cmake) endif() @@ -930,9 +930,9 @@ if(SDL3IMAGE_WEBP) message(${fatal_error} "libwebp NOT found") endif() endif() - if(SDL3IMAGE_WEBP_ENABLED) + if(SDLIMAGE_WEBP_ENABLED) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_WEBP) - if(SDL3IMAGE_WEBP_SHARED) + if(SDLIMAGE_WEBP_SHARED) target_include_directories(${sdl3_image_target_name} PRIVATE $ $ @@ -947,7 +947,7 @@ if(SDL3IMAGE_WEBP) target_get_dynamic_library(dynamic_webp WebP::webp) message(STATUS "Dynamic libwebp: ${dynamic_webp}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_WEBP_DYNAMIC=\"${dynamic_webp}\"") - if(SDL3IMAGE_WEBP_VENDORED) + if(SDLIMAGE_WEBP_VENDORED) add_dependencies(${sdl3_image_target_name} WebP::webp WebP::webpdemux) endif() else() @@ -956,31 +956,31 @@ if(SDL3IMAGE_WEBP) endif() endif() -list(APPEND SDL3IMAGE_BACKENDS XCF) -set(SDL3IMAGE_XCF_ENABLED FALSE) -if(SDL3IMAGE_XCF) - set(SDL3IMAGE_XCF_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS XCF) +set(SDLIMAGE_XCF_ENABLED FALSE) +if(SDLIMAGE_XCF) + set(SDLIMAGE_XCF_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_XCF) endif() -list(APPEND SDL3IMAGE_BACKENDS XPM) -set(SDL3IMAGE_XPM_ENABLED FALSE) -if(SDL3IMAGE_XPM) - set(SDL3IMAGE_XPM_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS XPM) +set(SDLIMAGE_XPM_ENABLED FALSE) +if(SDLIMAGE_XPM) + set(SDLIMAGE_XPM_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_XPM) endif() -list(APPEND SDL3IMAGE_BACKENDS XV) -set(SDL3IMAGE_XV_ENABLED FALSE) -if(SDL3IMAGE_XV) - set(SDL3IMAGE_XV_ENABLED TRUE) +list(APPEND SDLIMAGE_BACKENDS XV) +set(SDLIMAGE_XV_ENABLED FALSE) +if(SDLIMAGE_XV) + set(SDLIMAGE_XV_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_XV) endif() # Restore BUILD_SHARED_LIBS -set(BUILD_SHARED_LIBS ${SDL3IMAGE_BUILD_SHARED_LIBS}) +set(BUILD_SHARED_LIBS ${SDLIMAGE_BUILD_SHARED_LIBS}) -if(SDL3IMAGE_INSTALL) +if(SDLIMAGE_INSTALL) install( TARGETS ${sdl3_image_target_name} EXPORT SDL3ImageExports @@ -1022,23 +1022,23 @@ if(SDL3IMAGE_INSTALL) endif() if(WIN32 AND NOT MINGW) - set(SDL3IMAGE_INSTALL_CMAKEDIR_ROOT_DEFAULT "cmake") + set(SDLIMAGE_INSTALL_CMAKEDIR_ROOT_DEFAULT "cmake") else() - set(SDL3IMAGE_INSTALL_CMAKEDIR_ROOT_DEFAULT "${CMAKE_INSTALL_LIBDIR}/cmake") + set(SDLIMAGE_INSTALL_CMAKEDIR_ROOT_DEFAULT "${CMAKE_INSTALL_LIBDIR}/cmake") endif() - set(SDL3IMAGE_INSTALL_CMAKEDIR_ROOT "${SDL3IMAGE_INSTALL_CMAKEDIR_ROOT_DEFAULT}" CACHE STRING "Root folder where to install SDL3_imageConfig.cmake related files (SDL3_image subfolder for MSVC projects)") + set(SDLIMAGE_INSTALL_CMAKEDIR_ROOT "${SDLIMAGE_INSTALL_CMAKEDIR_ROOT_DEFAULT}" CACHE STRING "Root folder where to install SDL3_imageConfig.cmake related files (SDL3_image subfolder for MSVC projects)") set(SDLIMAGE_PKGCONFIG_INSTALLDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") if(WIN32 AND NOT MINGW) - set(SDL3IMAGE_INSTALL_CMAKEDIR "${SDL3IMAGE_INSTALL_CMAKEDIR_ROOT}") + set(SDLIMAGE_INSTALL_CMAKEDIR "${SDLIMAGE_INSTALL_CMAKEDIR_ROOT}") set(LICENSES_PREFIX "licenses/SDL3_image") else() - set(SDL3IMAGE_INSTALL_CMAKEDIR "${SDL3IMAGE_INSTALL_CMAKEDIR_ROOT}/SDL3_image") + set(SDLIMAGE_INSTALL_CMAKEDIR "${SDLIMAGE_INSTALL_CMAKEDIR_ROOT}/SDL3_image") set(LICENSES_PREFIX "${CMAKE_INSTALL_DATAROOTDIR}/licenses/SDL3_image") endif() configure_package_config_file(cmake/SDL3_imageConfig.cmake.in SDL3_imageConfig.cmake - INSTALL_DESTINATION "${SDL3IMAGE_INSTALL_CMAKEDIR}" + INSTALL_DESTINATION "${SDLIMAGE_INSTALL_CMAKEDIR}" ) write_basic_package_version_file("${PROJECT_BINARY_DIR}/SDL3_imageConfigVersion.cmake" COMPATIBILITY AnyNewerVersion @@ -1048,13 +1048,13 @@ if(SDL3IMAGE_INSTALL) "${CMAKE_CURRENT_BINARY_DIR}/SDL3_imageConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/SDL3_imageConfigVersion.cmake" ${INSTALL_EXTRA_CMAKE_MODULES} - DESTINATION "${SDL3IMAGE_INSTALL_CMAKEDIR}" + DESTINATION "${SDLIMAGE_INSTALL_CMAKEDIR}" COMPONENT devel ) install(EXPORT SDL3ImageExports FILE ${sdl3_image_target_name}-targets.cmake NAMESPACE SDL3_image:: - DESTINATION "${SDL3IMAGE_INSTALL_CMAKEDIR}" + DESTINATION "${SDLIMAGE_INSTALL_CMAKEDIR}" COMPONENT devel ) @@ -1075,7 +1075,7 @@ if(SDL3IMAGE_INSTALL) COMPONENT library ) - if(SDL3IMAGE_INSTALL_CPACK) + if(SDLIMAGE_INSTALL_CPACK) if(SDL2COMPAT_FRAMEWORK) set(CPACK_GENERATOR "DragNDrop") elseif(MSVC) @@ -1091,27 +1091,27 @@ if(SDL3IMAGE_INSTALL) include(CPack) endif() - if(SDL3IMAGE_INSTALL_MAN) - sdl_get_git_revision_hash(SDL3IMAGE_REVISION) + if(SDLIMAGE_INSTALL_MAN) + sdl_get_git_revision_hash(SDLIMAGE_REVISION) SDL_generate_manpages( HEADERS_DIR "${PROJECT_SOURCE_DIR}/include/SDL3_image" SYMBOL "IMG_Init" WIKIHEADERS_PL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build-scripts/wikiheaders.pl" - REVISION "${SDL3IMAGE_REVISION}" + REVISION "${SDLIMAGE_REVISION}" ) endif() endif() -if(SDL3IMAGE_SAMPLES) +if(SDLIMAGE_SAMPLES) add_executable(showanim examples/showanim.c) add_executable(showimage examples/showimage.c) foreach(prog showanim showimage) - sdl_add_warning_options(${prog} WARNING_AS_ERROR ${SDL3IMAGE_WERROR}) + sdl_add_warning_options(${prog} WARNING_AS_ERROR ${SDLIMAGE_WERROR}) target_link_libraries(${prog} PRIVATE SDL3_image::${sdl3_image_target_name}) target_link_libraries(${prog} PRIVATE ${sdl3_target_name}) - if(SDL3IMAGE_SAMPLES_INSTALL) + if(SDLIMAGE_SAMPLES_INSTALL) install(TARGETS ${prog} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) @@ -1122,7 +1122,7 @@ if(SDL3IMAGE_SAMPLES) endforeach() endif() -if(SDL3IMAGE_TESTS) +if(SDLIMAGE_TESTS) enable_testing() add_subdirectory(test) endif() @@ -1130,8 +1130,8 @@ endif() set(available_deps) set(unavailable_deps) -foreach(dep IN LISTS SDL3IMAGE_BACKENDS) - set(var SDL3IMAGE_${dep}_ENABLED) +foreach(dep IN LISTS SDLIMAGE_BACKENDS) + set(var SDLIMAGE_${dep}_ENABLED) if(NOT DEFINED ${var}) message(AUTHOR_WARNING "${var} not defined") endif() diff --git a/README.txt b/README.txt index 9fe97809..0fe06b9a 100644 --- a/README.txt +++ b/README.txt @@ -31,7 +31,7 @@ This library is under the zlib License, see the file "LICENSE.txt" for details. Note: Support for AVIF, JPEG-XL, TIFF, and WebP are not included by default because of the size of the decode libraries, but you can get them by running external/download.sh -- When building with CMake, you can enable the appropriate SDL3IMAGE_* options defined in CMakeLists.txt. SDL3IMAGE_VENDORED allows switching between system and vendored libraries. +- When building with CMake, you can enable the appropriate SDLIMAGE_* options defined in CMakeLists.txt. SDLIMAGE_VENDORED allows switching between system and vendored libraries. - When building with configure/make, you can build and install them normally and the configure script will detect and use them. - When building with Visual Studio, you will need to build the libraries and then add the appropriate LOAD_* preprocessor define to the Visual Studio project. - When building with Xcode, you can edit the config at the top of the project to enable them, and you will need to include the appropriate framework in your application. diff --git a/VisualC/pkg-support/cmake/sdl3_image-config.cmake b/VisualC/pkg-support/cmake/sdl3_image-config.cmake index 366bd857..e26a5f8c 100644 --- a/VisualC/pkg-support/cmake/sdl3_image-config.cmake +++ b/VisualC/pkg-support/cmake/sdl3_image-config.cmake @@ -11,32 +11,32 @@ cmake_minimum_required(VERSION 3.0) set(SDL3_image_FOUND TRUE) -set(SDL3IMAGE_AVIF FALSE) -set(SDL3IMAGE_BMP TRUE) -set(SDL3IMAGE_GIF TRUE) -set(SDL3IMAGE_JPG TRUE) -set(SDL3IMAGE_JXL FALSE) -set(SDL3IMAGE_LBM TRUE) -set(SDL3IMAGE_PCX TRUE) -set(SDL3IMAGE_PNG TRUE) -set(SDL3IMAGE_PNM TRUE) -set(SDL3IMAGE_QOI TRUE) -set(SDL3IMAGE_SVG TRUE) -set(SDL3IMAGE_TGA TRUE) -set(SDL3IMAGE_TIF FALSE) -set(SDL3IMAGE_XCF FALSE) -set(SDL3IMAGE_XPM TRUE) -set(SDL3IMAGE_XV TRUE) -set(SDL3IMAGE_WEBP FALSE) +set(SDLIMAGE_AVIF FALSE) +set(SDLIMAGE_BMP TRUE) +set(SDLIMAGE_GIF TRUE) +set(SDLIMAGE_JPG TRUE) +set(SDLIMAGE_JXL FALSE) +set(SDLIMAGE_LBM TRUE) +set(SDLIMAGE_PCX TRUE) +set(SDLIMAGE_PNG TRUE) +set(SDLIMAGE_PNM TRUE) +set(SDLIMAGE_QOI TRUE) +set(SDLIMAGE_SVG TRUE) +set(SDLIMAGE_TGA TRUE) +set(SDLIMAGE_TIF FALSE) +set(SDLIMAGE_XCF FALSE) +set(SDLIMAGE_XPM TRUE) +set(SDLIMAGE_XV TRUE) +set(SDLIMAGE_WEBP FALSE) -set(SDL3IMAGE_JPG_SAVE FALSE) -set(SDL3IMAGE_PNG_SAVE FALSE) +set(SDLIMAGE_JPG_SAVE FALSE) +set(SDLIMAGE_PNG_SAVE FALSE) -set(SDL3IMAGE_VENDORED FALSE) +set(SDLIMAGE_VENDORED FALSE) -set(SDL3IMAGE_BACKEND_IMAGEIO FALSE) -set(SDL3IMAGE_BACKEND_STB TRUE) -set(SDL3IMAGE_BACKEND_WIC FALSE) +set(SDLIMAGE_BACKEND_IMAGEIO FALSE) +set(SDLIMAGE_BACKEND_STB TRUE) +set(SDLIMAGE_BACKEND_WIC FALSE) if(CMAKE_SIZEOF_VOID_P STREQUAL "4") set(_sdl_arch_subdir "x86") diff --git a/Xcode/pkg-support/resources/CMake/sdl3_image-config.cmake b/Xcode/pkg-support/resources/CMake/sdl3_image-config.cmake index 27f79fc7..307fd695 100644 --- a/Xcode/pkg-support/resources/CMake/sdl3_image-config.cmake +++ b/Xcode/pkg-support/resources/CMake/sdl3_image-config.cmake @@ -12,32 +12,32 @@ set_package_properties(SDL3_image PROPERTIES set(SDL3_image_FOUND TRUE) -set(SDL3IMAGE_AVIF FALSE) -set(SDL3IMAGE_BMP TRUE) -set(SDL3IMAGE_GIF TRUE) -set(SDL3IMAGE_JPG TRUE) -set(SDL3IMAGE_JXL FALSE) -set(SDL3IMAGE_LBM TRUE) -set(SDL3IMAGE_PCX TRUE) -set(SDL3IMAGE_PNG TRUE) -set(SDL3IMAGE_PNM TRUE) -set(SDL3IMAGE_QOI TRUE) -set(SDL3IMAGE_SVG TRUE) -set(SDL3IMAGE_TGA TRUE) -set(SDL3IMAGE_TIF TRUE) -set(SDL3IMAGE_XCF TRUE) -set(SDL3IMAGE_XPM TRUE) -set(SDL3IMAGE_XV TRUE) -set(SDL3IMAGE_WEBP FALSE) - -set(SDL3IMAGE_JPG_SAVE FALSE) -set(SDL3IMAGE_PNG_SAVE FALSE) - -set(SDL3IMAGE_VENDORED FALSE) - -set(SDL3IMAGE_BACKEND_IMAGEIO FALSE) -set(SDL3IMAGE_BACKEND_STB TRUE) -set(SDL3IMAGE_BACKEND_WIC FALSE) +set(SDLIMAGE_AVIF FALSE) +set(SDLIMAGE_BMP TRUE) +set(SDLIMAGE_GIF TRUE) +set(SDLIMAGE_JPG TRUE) +set(SDLIMAGE_JXL FALSE) +set(SDLIMAGE_LBM TRUE) +set(SDLIMAGE_PCX TRUE) +set(SDLIMAGE_PNG TRUE) +set(SDLIMAGE_PNM TRUE) +set(SDLIMAGE_QOI TRUE) +set(SDLIMAGE_SVG TRUE) +set(SDLIMAGE_TGA TRUE) +set(SDLIMAGE_TIF TRUE) +set(SDLIMAGE_XCF TRUE) +set(SDLIMAGE_XPM TRUE) +set(SDLIMAGE_XV TRUE) +set(SDLIMAGE_WEBP FALSE) + +set(SDLIMAGE_JPG_SAVE FALSE) +set(SDLIMAGE_PNG_SAVE FALSE) + +set(SDLIMAGE_VENDORED FALSE) + +set(SDLIMAGE_BACKEND_IMAGEIO FALSE) +set(SDLIMAGE_BACKEND_STB TRUE) +set(SDLIMAGE_BACKEND_WIC FALSE) string(REGEX REPLACE "SDL3_image\\.framework.*" "SDL3_image.framework" _sdl3image_framework_path "${CMAKE_CURRENT_LIST_DIR}") string(REGEX REPLACE "SDL3_image\\.framework.*" "" _sdl3image_framework_parent_path "${CMAKE_CURRENT_LIST_DIR}") diff --git a/build-scripts/android-prefab.sh b/build-scripts/android-prefab.sh index dec712c6..a66bbd3f 100755 --- a/build-scripts/android-prefab.sh +++ b/build-scripts/android-prefab.sh @@ -65,27 +65,27 @@ build_cmake_projects() { for build_shared_libs in ON OFF; do echo "Configuring CMake project for $android_abi (shared=${build_shared_libs})" cmake -S "${sdlimage_root}" -B "${build_root}/build_${android_abi}/shared_${build_shared_libs}" \ - -DSDL3IMAGE_DEPS_SHARED=ON \ - -DSDL3IMAGE_VENDORED=ON \ - -DSDL3IMAGE_BACKEND_STB=OFF \ - -DSDL3IMAGE_AVIF=OFF \ - -DSDL3IMAGE_BMP=ON \ - -DSDL3IMAGE_GIF=ON \ - -DSDL3IMAGE_JPG=ON \ - -DSDL3IMAGE_JXL=OFF \ + -DSDLIMAGE_DEPS_SHARED=ON \ + -DSDLIMAGE_VENDORED=ON \ + -DSDLIMAGE_BACKEND_STB=OFF \ + -DSDLIMAGE_AVIF=OFF \ + -DSDLIMAGE_BMP=ON \ + -DSDLIMAGE_GIF=ON \ + -DSDLIMAGE_JPG=ON \ + -DSDLIMAGE_JXL=OFF \ -DSJPEG_ANDROID_NDK_PATH="${ANDROID_NDK_HOME}" \ - -DSDL3IMAGE_LBM=ON \ - -DSDL3IMAGE_PCX=ON \ - -DSDL3IMAGE_PNG=ON \ - -DSDL3IMAGE_PNM=ON \ - -DSDL3IMAGE_QOI=ON \ - -DSDL3IMAGE_SVG=ON \ - -DSDL3IMAGE_TGA=ON \ - -DSDL3IMAGE_TIF=ON \ - -DSDL3IMAGE_WEBP=ON \ - -DSDL3IMAGE_XCF=ON \ - -DSDL3IMAGE_XPM=ON \ - -DSDL3IMAGE_XV=ON \ + -DSDLIMAGE_LBM=ON \ + -DSDLIMAGE_PCX=ON \ + -DSDLIMAGE_PNG=ON \ + -DSDLIMAGE_PNM=ON \ + -DSDLIMAGE_QOI=ON \ + -DSDLIMAGE_SVG=ON \ + -DSDLIMAGE_TGA=ON \ + -DSDLIMAGE_TIF=ON \ + -DSDLIMAGE_WEBP=ON \ + -DSDLIMAGE_XCF=ON \ + -DSDLIMAGE_XPM=ON \ + -DSDLIMAGE_XV=ON \ -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \ -DSDL${sdlimage_major}_DIR="${sdl_build_root}/build_${android_abi}/prefix/lib/cmake/SDL${sdlimage_major}" \ -DANDROID_PLATFORM=${android_platform} \ diff --git a/cmake/SDL3_imageConfig.cmake.in b/cmake/SDL3_imageConfig.cmake.in index d8507cb0..a3862a4b 100644 --- a/cmake/SDL3_imageConfig.cmake.in +++ b/cmake/SDL3_imageConfig.cmake.in @@ -8,40 +8,40 @@ set_package_properties(SDL3_image PROPERTIES set(SDL3_image_FOUND ON) -set(SDL3IMAGE_AVIF @SDL3IMAGE_AVIF_ENABLED@) -set(SDL3IMAGE_AVIF_SHARED @SDL3IMAGE_AVIF_SHARED@) -set(SDL3IMAGE_BMP @SDL3IMAGE_BMP_ENABLED@) -set(SDL3IMAGE_GIF @SDL3IMAGE_GIF_ENABLED@) -set(SDL3IMAGE_JPG @SDL3IMAGE_JPG_ENABLED@) -set(SDL3IMAGE_JPG_SHARED @SDL3IMAGE_JPG_SHARED@) -set(SDL3IMAGE_JXL @SDL3IMAGE_JXL_ENABLED@) -set(SDL3IMAGE_JXL_SHARED @SDL3IMAGE_JXL_SHARED@) -set(SDL3IMAGE_LBM @SDL3IMAGE_LBM_ENABLED@) -set(SDL3IMAGE_PCX @SDL3IMAGE_PCX_ENABLED@) -set(SDL3IMAGE_PNG @SDL3IMAGE_PNG_ENABLED@) -set(SDL3IMAGE_PNG_SHARED @SDL3IMAGE_PNG_SHARED@) -set(SDL3IMAGE_PNM @SDL3IMAGE_PNM_ENABLED@) -set(SDL3IMAGE_QOI @SDL3IMAGE_QOI_ENABLED@) -set(SDL3IMAGE_SVG @SDL3IMAGE_SVG_ENABLED@) -set(SDL3IMAGE_TGA @SDL3IMAGE_TGA_ENABLED@) -set(SDL3IMAGE_TIF @SDL3IMAGE_TIF_ENABLED@) -set(SDL3IMAGE_TIF_SHARED @SDL3IMAGE_TIF_SHARED@) -set(SDL3IMAGE_XCF @SDL3IMAGE_XCF_ENABLED@) -set(SDL3IMAGE_XPM @SDL3IMAGE_XPM_ENABLED@) -set(SDL3IMAGE_XV @SDL3IMAGE_XV_ENABLED@) -set(SDL3IMAGE_WEBP @SDL3IMAGE_WEBP_ENABLED@) -set(SDL3IMAGE_WEBP_SHARED @SDL3IMAGE_WEBP_SHARED@) - -set(SDL3IMAGE_JPG_SAVE @SDL3IMAGE_JPG_SAVE@) -set(SDL3IMAGE_PNG_SAVE @SDL3IMAGE_PNG_SAVE@) - -set(SDL3IMAGE_VENDORED @SDL3IMAGE_VENDORED@) - -set(SDL3IMAGE_BACKEND_IMAGEIO @SDL3IMAGE_BACKEND_IMAGEIO@) -set(SDL3IMAGE_BACKEND_STB @SDL3IMAGE_BACKEND_STB@) -set(SDL3IMAGE_BACKEND_WIC @SDL3IMAGE_BACKEND_WIC@) - -set(SDL3IMAGE_SDL3_REQUIRED_VERSION @SDL_REQUIRED_VERSION@) +set(SDLIMAGE_AVIF @SDLIMAGE_AVIF_ENABLED@) +set(SDLIMAGE_AVIF_SHARED @SDLIMAGE_AVIF_SHARED@) +set(SDLIMAGE_BMP @SDLIMAGE_BMP_ENABLED@) +set(SDLIMAGE_GIF @SDLIMAGE_GIF_ENABLED@) +set(SDLIMAGE_JPG @SDLIMAGE_JPG_ENABLED@) +set(SDLIMAGE_JPG_SHARED @SDLIMAGE_JPG_SHARED@) +set(SDLIMAGE_JXL @SDLIMAGE_JXL_ENABLED@) +set(SDLIMAGE_JXL_SHARED @SDLIMAGE_JXL_SHARED@) +set(SDLIMAGE_LBM @SDLIMAGE_LBM_ENABLED@) +set(SDLIMAGE_PCX @SDLIMAGE_PCX_ENABLED@) +set(SDLIMAGE_PNG @SDLIMAGE_PNG_ENABLED@) +set(SDLIMAGE_PNG_SHARED @SDLIMAGE_PNG_SHARED@) +set(SDLIMAGE_PNM @SDLIMAGE_PNM_ENABLED@) +set(SDLIMAGE_QOI @SDLIMAGE_QOI_ENABLED@) +set(SDLIMAGE_SVG @SDLIMAGE_SVG_ENABLED@) +set(SDLIMAGE_TGA @SDLIMAGE_TGA_ENABLED@) +set(SDLIMAGE_TIF @SDLIMAGE_TIF_ENABLED@) +set(SDLIMAGE_TIF_SHARED @SDLIMAGE_TIF_SHARED@) +set(SDLIMAGE_XCF @SDLIMAGE_XCF_ENABLED@) +set(SDLIMAGE_XPM @SDLIMAGE_XPM_ENABLED@) +set(SDLIMAGE_XV @SDLIMAGE_XV_ENABLED@) +set(SDLIMAGE_WEBP @SDLIMAGE_WEBP_ENABLED@) +set(SDLIMAGE_WEBP_SHARED @SDLIMAGE_WEBP_SHARED@) + +set(SDLIMAGE_JPG_SAVE @SDLIMAGE_JPG_SAVE@) +set(SDLIMAGE_PNG_SAVE @SDLIMAGE_PNG_SAVE@) + +set(SDLIMAGE_VENDORED @SDLIMAGE_VENDORED@) + +set(SDLIMAGE_BACKEND_IMAGEIO @SDLIMAGE_BACKEND_IMAGEIO@) +set(SDLIMAGE_BACKEND_STB @SDLIMAGE_BACKEND_STB@) +set(SDLIMAGE_BACKEND_WIC @SDLIMAGE_BACKEND_WIC@) + +set(SDLIMAGE_SDL3_REQUIRED_VERSION @SDL_REQUIRED_VERSION@) if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3_image-shared-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/SDL3_image-shared-targets.cmake") @@ -49,18 +49,18 @@ endif() if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3_image-static-targets.cmake") - if(SDL3IMAGE_VENDORED) - if(SDL3IMAGE_AVIF AND NOT SDL3IMAGE_AVIF_SHARED) + if(SDLIMAGE_VENDORED) + if(SDLIMAGE_AVIF AND NOT SDLIMAGE_AVIF_SHARED) find_package(Threads) endif() - if(SDL3IMAGE_JXL AND NOT SDL3IMAGE_JXL_SHARED) + if(SDLIMAGE_JXL AND NOT SDLIMAGE_JXL_SHARED) include(CheckLanguage) check_language(CXX) if(NOT CMAKE_CXX_COMPILER AND NOT _sdl3image_nowarning) message(WARNING "CXX language not enabled. Linking to SDL3_image::SDL3_image-static might fail.") endif() endif() - if(SDL3IMAGE_TIF AND NOT SDL3IMAGE_TIF_SHARED) + if(SDLIMAGE_TIF AND NOT SDLIMAGE_TIF_SHARED) if(NOT TARGET CMath::CMath) add_library(CMath::CMath INTERFACE IMPORTED) find_library(CMATH_LIBRARY NAMES m) @@ -69,7 +69,7 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3_image-static-targets.cmake") endif() endif() endif() - if(SDL3IMAGE_WEBP AND NOT SDL3IMAGE_WEBP_SHARED) + if(SDLIMAGE_WEBP AND NOT SDLIMAGE_WEBP_SHARED) find_package(Threads) endif() else() @@ -78,7 +78,7 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3_image-static-targets.cmake") include(CMakeFindDependencyMacro) - if(SDL3IMAGE_AVIF AND NOT TARGET avif AND NOT SDL3IMAGE_AVIF_SHARED) + if(SDLIMAGE_AVIF AND NOT TARGET avif AND NOT SDLIMAGE_AVIF_SHARED) find_package(libavif 1.0 QUIET) if(NOT libavif_FOUND) find_package(libavif @LIBAVIF_MINIMUM_VERSION@ QUIET) @@ -89,24 +89,24 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3_image-static-targets.cmake") endif() endif() - if(SDL3IMAGE_JPG AND NOT TARGET JPEG::JPEG AND NOT SDL3IMAGE_JPG_SHARED) + if(SDLIMAGE_JPG AND NOT TARGET JPEG::JPEG AND NOT SDLIMAGE_JPG_SHARED) find_dependency(JPEG) endif() - if(SDL3IMAGE_JXL AND NOT TARGET libjxl::libjxl) + if(SDLIMAGE_JXL AND NOT TARGET libjxl::libjxl) list(APPEND libjxl_ROOT "${CMAKE_CURRENT_LIST_DIR}") find_dependency(libjxl) endif() - if(SDL3IMAGE_PNG AND NOT TARGET PNG::PNG AND NOT SDL3IMAGE_PNG_SHARED) + if(SDLIMAGE_PNG AND NOT TARGET PNG::PNG AND NOT SDLIMAGE_PNG_SHARED) find_dependency(PNG) endif() - if(SDL3IMAGE_TIF AND NOT TARGET TIFF::TIFF) + if(SDLIMAGE_TIF AND NOT TARGET TIFF::TIFF) find_dependency(TIFF) endif() - if(SDL3IMAGE_WEBP AND NOT TARGET WebP::webp AND NOT SDL3IMAGE_WEBP_SHARED) + if(SDLIMAGE_WEBP AND NOT TARGET WebP::webp AND NOT SDLIMAGE_WEBP_SHARED) list(APPEND webp_ROOT "${CMAKE_CURRENT_LIST_DIR}") find_dependency(webp) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 64e974d6..d3ed080b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -34,11 +34,11 @@ function(add_sdl_image_test_executable TARGET) target_compile_definitions(${TARGET} PRIVATE $ - "SDL_IMAGE_SAVE_AVIF=$" - "SDL_IMAGE_SAVE_JPG=$" - "SDL_IMAGE_SAVE_PNG=$" + "SDL_IMAGE_SAVE_AVIF=$" + "SDL_IMAGE_SAVE_JPG=$" + "SDL_IMAGE_SAVE_PNG=$" ) - sdl_add_warning_options(${TARGET} WARNING_AS_ERROR ${SDL3IMAGE_WERROR}) + sdl_add_warning_options(${TARGET} WARNING_AS_ERROR ${SDLIMAGE_WERROR}) target_link_libraries(${TARGET} PRIVATE SDL3_image::SDL3_image SDL3::SDL3_test SDL3::SDL3) add_test( @@ -57,7 +57,7 @@ function(add_sdl_image_test_executable TARGET) ENVIRONMENT "${TESTS_ENVIRONMENT}" TIMEOUT 30 ) - if(SDL3IMAGE_TESTS_INSTALL) + if(SDLIMAGE_TESTS_INSTALL) set(installedtestsdir "${CMAKE_INSTALL_FULL_LIBEXECDIR}/installed-tests/${PROJECT_NAME}") configure_file(template.test.in "${TARGET}.test" @ONLY) install( @@ -65,7 +65,7 @@ function(add_sdl_image_test_executable TARGET) DESTINATION "${CMAKE_INSTALL_DATADIR}/installed-tests/${PROJECT_NAME}" ) endif() - if(SDL3IMAGE_TESTS_INSTALL) + if(SDLIMAGE_TESTS_INSTALL) install( TARGETS ${TARGET} DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/${PROJECT_NAME}" @@ -75,7 +75,7 @@ endfunction() add_sdl_image_test_executable(testimage main.c) -if(SDL3IMAGE_TESTS_INSTALL) +if(SDLIMAGE_TESTS_INSTALL) install( FILES ${RESOURCE_FILES} DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/${PROJECT_NAME}" diff --git a/test/README.md b/test/README.md index 0b4bc278..99deb4ee 100644 --- a/test/README.md +++ b/test/README.md @@ -4,7 +4,7 @@ Build-time tests ---------------- -Configure with `--enable-tests` (Autotools) or `-DSDL3IMAGE_TESTS` (CMake). +Configure with `--enable-tests` (Autotools) or `-DSDLIMAGE_TESTS` (CMake). Run build-time tests in the usual way, for example `make check` (Autotools), or `ctest` or `make test` (CMake). @@ -17,7 +17,7 @@ run on a target platform as a somewhat realistic equivalent of how a game would behave. Configure with `--enable-tests --enable-installed-tests` (Autotools) or -`-DSDL3IMAGE_TESTS -DSDL3IMAGE_TESTS_INSTALL` (CMake). +`-DSDLIMAGE_TESTS -DSDLIMAGE_TESTS_INSTALL` (CMake). The tests and their required resource files are installed into `${libexecdir}/installed-tests/SDL3_image`. When run, they will write