### Install Sample Programs Option Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables the installation of the SDL3_image sample programs. Requires sample programs to be built and the main install target to be enabled. ```cmake cmake_dependent_option(SDLIMAGE_SAMPLES_INSTALL "Install the SDL3_image sample program(s)" OFF "SDLIMAGE_SAMPLES;SDLIMAGE_INSTALL" OFF) ``` -------------------------------- ### Install Man Pages Option Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables the installation of man pages for SDL3_image. Requires the main install target to be enabled. ```cmake cmake_dependent_option(SDLIMAGE_INSTALL_MAN "Install man pages for SDL3_image" OFF "SDLIMAGE_INSTALL" OFF) ``` -------------------------------- ### Add Sample Executables Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Adds specific example executables for SDL Image, such as showanim, showimage, showclipboard, and showgpuimage. ```cmake add_sdl_image_example_executable(showanim examples/showanim.c) add_sdl_image_example_executable(showimage examples/showimage.c) add_sdl_image_example_executable(showclipboard examples/showclipboard.c) add_sdl_image_example_executable(showgpuimage examples/showgpuimage.c) ``` -------------------------------- ### Enable SDL3_image Install Target Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Controls the installation of the SDL3_image target. Enabled only if the root project is enabled and installation is permitted. ```cmake cmake_dependent_option(SDLIMAGE_INSTALL "Enable SDL3_image install target" ${SDLIMAGE_ROOTPROJECT} "${sdlimage_install_enableable}" OFF) ``` -------------------------------- ### Install Unit Tests Option Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables the installation of unit tests for SDL3_image. ```cmake option(SDLIMAGE_TESTS_INSTALL "Install unit tests?" OFF) ``` -------------------------------- ### Enable SDL3_image CPack Installation Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the creation of a binary SDL3_image archive using CPack, dependent on the main install target being enabled. ```cmake cmake_dependent_option(SDLIMAGE_INSTALL_CPACK "Create binary SDL3_image archive using CPack" ${SDLIMAGE_ROOTPROJECT} "SDLIMAGE_INSTALL" OFF) ``` -------------------------------- ### Add SDL Image Example Executable Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Defines a function to add sample executables for SDL Image. Handles Android builds by creating a shared library. ```cmake function(add_sdl_image_example_executable TARGET) if(ANDROID) add_library(${TARGET} SHARED ${ARGN}) else() add_executable(${TARGET} ${ARGN}) endif() sdl_add_warning_options(${TARGET} WARNING_AS_ERROR ${SDLIMAGE_WERROR}) sdl_target_link_options_no_undefined(${TARGET}) target_link_libraries(${TARGET} PRIVATE SDL3_image::${sdl3_image_target_name}) target_link_libraries(${TARGET} PRIVATE ${sdl3_target_name}) if(SDLIMAGE_SAMPLES_INSTALL) install(TARGETS ${TARGET} RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3_image" ) if(MSVC) SDL_install_pdb("${TARGET}" "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3_image") endif() endif() endfunction() ``` -------------------------------- ### Install Test Resources Conditionally Source: https://github.com/libsdl-org/sdl_image/blob/main/test/CMakeLists.txt Installs resource files for tests if the SDLIMAGE_TESTS_INSTALL option is enabled and the target platform is not Emscripten. This ensures test assets are available in the installation directory. ```cmake if(SDLIMAGE_TESTS_INSTALL) if(NOT EMSCRIPTEN) install( FILES ${RESOURCE_FILES} DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/${PROJECT_NAME}" ) endif() endif() ``` -------------------------------- ### Conditional Installation Enablement Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Determines if SDL3_image can be installed. Installation is disabled if SDL3 is built in the same build and not installed. ```cmake 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(sdlimage_install_enableable OFF) endif() ``` -------------------------------- ### Find System libpng Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Searches for an installed system libpng library. If found, it enables the libpng backend for SDL Image. ```cmake find_package(PNG ${required}) if(PNG_FOUND) message(STATUS "${PROJECT_NAME}: Using system libpng") set(SDLIMAGE_LIBPNG_ENABLED TRUE) if(NOT SDLIMAGE_PNG_SHARED) list(APPEND PC_REQUIRES libpng) endif() else() message(${FATAL_ERROR} "libpng NOT found") endif() ``` -------------------------------- ### Find System JPEG Library Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Finds and configures the system's libjpeg library for use with SDL3_image. Requires libjpeg to be installed and discoverable by find_package. ```cmake find_package(JPEG ${required}) if(JPEG_FOUND) message(STATUS "${PROJECT_NAME}: Using system libjpeg") set(SDLIMAGE_JPG_ENABLED TRUE) if(NOT SDLIMAGE_JPG_SHARED) list(APPEND PC_REQUIRES libjpeg) endif() else() message(${fatal_error} "libjpeg NOT found") endif() ``` -------------------------------- ### Create Relocatable Package Option Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the creation of a relocatable SDL_image package, typically for MSVC builds and when installation is enabled. ```cmake cmake_dependent_option(SDLIMAGE_RELOCATABLE "Create relocatable SDL_image package" "${MSVC}" SDLIMAGE_INSTALL OFF) ``` -------------------------------- ### Build Sample Programs Option Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables the building of the SDL3_image sample programs. ```cmake option(SDLIMAGE_SAMPLES "Build the SDL3_image sample program(s)" ${SDLIMAGE_SAMPLES_DEFAULT}) ``` -------------------------------- ### Build and Run SDL_image Project Source: https://github.com/libsdl-org/sdl_image/blob/main/docs/INTRO-cmake.md Commands to build your project using CMake and then run the executable. The path to the executable depends on your operating system. ```sh cmake -S . -B build cmake --build build ``` ```sh cd build/Debug ./hello ``` ```sh cd build ./hello ``` -------------------------------- ### Configure System libwebp Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Finds and configures the system's libwebp library. If not found, it triggers a fatal error. ```cmake find_package(webp ${required}) if(webp_FOUND) message(STATUS "${PROJECT_NAME}: Using system libwebp") set(SDLIMAGE_WEBP_ENABLED TRUE) if(NOT SDLIMAGE_WEBP_SHARED) list(APPEND PC_REQUIRES libwebp libwebpdemux libwebpmux) list(APPEND INSTALL_EXTRA_CMAKE_MODULES cmake/Findwebp.cmake) endif() else() message(${fatal_error} "libwebp NOT found") endif() ``` -------------------------------- ### Build SDL_image Project with Emscripten Source: https://github.com/libsdl-org/sdl_image/blob/main/docs/INTRO-emscripten.md Use emcmake and emmake to configure, build, and compile your SDL_image project for Emscripten. After building, serve the build directory with a web server to run the application in a browser. ```sh emcmake cmake -S . -B build cd build emmake make ``` -------------------------------- ### Create Release Assets with GitHub Actions Source: https://github.com/libsdl-org/sdl_image/blob/main/docs/release_checklist.md Run this script to have GitHub Actions create release assets. Ensure the revision string in the archives is correct. Replace with the actual release tag. ```bash build-scripts/create-release.py -R libsdl-org/SDL_image --ref ``` -------------------------------- ### Configure WebP Dynamic Library Loading Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets up include directories and defines for dynamic loading of WebP libraries. It checks for the availability of WebP, WebPdemux, and libwebpmux, and configures compile definitions based on whether these libraries are dynamically loaded. ```cmake if(NOT DEFINED SDLIMAGE_DYNAMIC_WEBP AND NOT DEFINED SDLIMAGE_DYNAMIC_WEBPDEMUX AND NOT DEFINED SDLIMAGE_DYNAMIC_WEBPMUX) target_include_directories(${sdl3_image_target_name} PRIVATE $ $ $ $ $ $ $ $ $ ) if(SDLIMAGE_WEBP_VENDORED) add_dependencies(${sdl3_image_target_name} WebP::webp WebP::webpdemux WebP::libwebpmux) endif() endif() target_get_dynamic_library(SDLIMAGE_DYNAMIC_WEBPDEMUX WebP::webpdemux) message(STATUS "Dynamic libwebpdemux: ${SDLIMAGE_DYNAMIC_WEBPDEMUX}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_WEBPDEMUX_DYNAMIC=\"${SDLIMAGE_DYNAMIC_WEBPDEMUX}\"") target_get_dynamic_library(SDLIMAGE_DYNAMIC_WEBPMUX WebP::libwebpmux) message(STATUS "Dynamic libwebpmux: ${SDLIMAGE_DYNAMIC_WEBPMUX}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_WEBPMUX_DYNAMIC=\"${SDLIMAGE_DYNAMIC_WEBPMUX}\"") target_get_dynamic_library(SDLIMAGE_DYNAMIC_WEBP WebP::webp) message(STATUS "Dynamic libwebp: ${SDLIMAGE_DYNAMIC_WEBP}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_WEBP_DYNAMIC=\"${SDLIMAGE_DYNAMIC_WEBP}\"") ``` -------------------------------- ### Verify Versioning Consistency Source: https://github.com/libsdl-org/sdl_image/blob/main/docs/release_checklist.md Execute this script to verify that all versioning information across the project is consistent. ```bash ./build-scripts/test-versioning.sh ``` -------------------------------- ### Configure Vendored JPEG Library Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets up the build to use a vendored libjpeg library for SDL3_image. This involves adding the subdirectory and setting build options. ```cmake set(BUILD_SHARED_LIBS ${SDLIMAGE_JPG_SHARED}) add_subdirectory(external/jpeg external/jpeg-build EXCLUDE_FROM_ALL) register_license(jpeg external/jpeg/COPYING) 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 SDLIMAGE_JPG_SHARED) list(APPEND PC_LIBS -l$) endif() ``` -------------------------------- ### Configure ImageIO Backend for Apple Platforms Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Configures the ImageIO backend for SDL_image on Apple platforms. This involves enabling Objective-C, setting framework search paths, and linking necessary frameworks. ```cmake list(APPEND SDLIMAGE_BACKENDS IMAGEIO) set(SDLIMAGE_IMAGEIO_ENABLED FALSE) if(APPLE) if(SDLIMAGE_BACKEND_IMAGEIO) enable_language(OBJC) set(SDLIMAGE_IMAGEIO_ENABLED TRUE) if(CMAKE_VERSION VERSION_LESS "3.24") set(genex_FRAMEWORK "1:") else() set(genex_FRAMEWORK "LINK_LIBRARY:FRAMEWORK,") endif() if(CMAKE_SYSTEM_NAME MATCHES ".*(Darwin|MacOS).*") target_link_libraries(${sdl3_image_target_name} PRIVATE $<${genex_FRAMEWORK}ApplicationServices>) target_link_libraries(${sdl3_image_target_name} PRIVATE $<${genex_FRAMEWORK}Foundation>) else() target_link_libraries(${sdl3_image_target_name} PRIVATE $<${genex_FRAMEWORK}CoreGraphics> $<${genex_FRAMEWORK}Foundation> $<${genex_FRAMEWORK}ImageIO> $<${genex_FRAMEWORK}MobileCoreServices> $<${genex_FRAMEWORK}UIKit> ) endif() target_link_libraries(${sdl3_image_target_name} PRIVATE objc) target_sources(${sdl3_image_target_name} PRIVATE src/IMG_ImageIO.m ) if (SDLIMAGE_PNG AND NOT SDLIMAGE_BACKEND_STB) target_compile_definitions(${sdl3_image_target_name} PRIVATE PNG_USES_IMAGEIO) endif() if (SDLIMAGE_JPG AND NOT SDLIMAGE_BACKEND_STB) target_compile_definitions(${sdl3_image_target_name} PRIVATE JPG_USES_IMAGEIO) endif() else() target_compile_definitions(${sdl3_image_target_name} PRIVATE SDL_IMAGE_USE_COMMON_BACKEND) endif() endif() ``` -------------------------------- ### Enable XV Backend Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the XV image format backend by adding it to the list of supported backends and defining LOAD_XV. ```cmake 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() ``` -------------------------------- ### Configure Vendored libpng for SDL Image Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets up the use of a vendored libpng library for SDL Image. This involves adding the libpng subdirectory, configuring build options, and registering licenses. ```cmake set(PNG_SHARED "${SDLIMAGE_PNG_SHARED}") set(SDLIMAGE_LIBPNG_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 SDLIMAGE_VENDORED) add_subdirectory(external/libpng external/libpng-build EXCLUDE_FROM_ALL) register_license(libpng external/libpng/LICENSE) if(SDLIMAGE_PNG_SHARED) set(PNG_LIBRARY png_shared) else() set(PNG_LIBRARY png_static) endif() 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(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}) ``` -------------------------------- ### Enable WIC Backend (Windows) Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Adds support for the Windows Imaging Component (WIC) backend. Only available on Windows. ```cmake cmake_dependent_option(SDLIMAGE_BACKEND_WIC "Add WIC backend (Windows Imaging Component)" OFF WIN32 OFF) ``` -------------------------------- ### Configure Vendored libwebp Build Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets up the build for a vendored libwebp library, disabling unnecessary sub-projects and configuring build options for shared or static linking. ```cmake set(SDLIMAGE_WEBP_ENABLED TRUE) set(WEBP_BUILD_ANIM_UTILS OFF CACHE BOOL "" FORCE) set(WEBP_BUILD_CWEBP OFF CACHE BOOL "" FORCE) set(WEBP_BUILD_DWEBP OFF CACHE BOOL "" FORCE) set(WEBP_BUILD_GIF2WEBP OFF CACHE BOOL "" FORCE) set(WEBP_BUILD_IMG2WEBP OFF CACHE BOOL "" FORCE) set(WEBP_BUILD_VWEBP OFF CACHE BOOL "" FORCE) set(WEBP_BUILD_WEBPINFO OFF CACHE BOOL "" FORCE) set(WEBP_BUILD_LIBWEBPMUX ON CACHE BOOL "" FORCE) set(WEBP_BUILD_WEBPMUX ON CACHE BOOL "" FORCE) set(WEBP_BUILD_EXTRAS OFF CACHE BOOL "" FORCE) message(STATUS "${PROJECT_NAME}: Using vendored libwebp") sdl_check_project_in_subfolder(external/libwebp libwebp SDLIMAGE_VENDORED) set(BUILD_SHARED_LIBS ${SDLIMAGE_WEBP_SHARED}) add_subdirectory(external/libwebp external/libwebp-build EXCLUDE_FROM_ALL) register_license(webp external/libwebp/COPYING) target_include_directories(${sdl3_image_target_name} PRIVATE external/libwebp/src) add_library(WebP::webp ALIAS webp) add_library(WebP::webpdemux ALIAS webpdemux) add_library(WebP::libwebpmux ALIAS libwebpmux) if(SDLIMAGE_WEBP_SHARED OR NOT SDLIMAGE_BUILD_SHARED_LIBS) list(APPEND INSTALL_EXTRA_TARGETS webp webpdemux libwebpmux) if(NOT SDLIMAGE_WEBP_SHARED) list(APPEND INSTALL_EXTRA_TARGETS sharpyuv) endif() endif() set_target_properties(webp PROPERTIES EXPORT_NAME "external_libwebp") set_target_properties(webpdemux PROPERTIES EXPORT_NAME "external_webpdemux") set_target_properties(libwebpmux PROPERTIES EXPORT_NAME "external_libwebpmux") set_target_properties(sharpyuv PROPERTIES EXPORT_NAME "external_sharpyuv") add_library(SDL3_image::external_libwebp ALIAS webp) ``` -------------------------------- ### Enable WIC Backend Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the Windows Imaging Component (WIC) backend for SDL_image. Use when SDLIMAGE_BACKEND_WIC is defined. ```cmake 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() ``` -------------------------------- ### Enable PNG and APNG Backends with libpng Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the PNG and APNG image format backends, requiring libpng to be available. This configuration is used when SDLIMAGE_LIBPNG_ENABLED is true. ```cmake set(SDLIMAGE_APNG_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE SDL_IMAGE_LIBPNG ) ``` -------------------------------- ### Enable XPM Backend Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the XPM image format backend by adding it to the list of supported backends and defining LOAD_XPM. ```cmake 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() ``` -------------------------------- ### Enable ImageIO Backend (macOS) Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the use of native macOS frameworks (ImageIO) for loading images. Only available on Apple platforms. ```cmake cmake_dependent_option(SDLIMAGE_BACKEND_IMAGEIO "Use native Mac OS X frameworks for loading images" ON APPLE OFF) ``` -------------------------------- ### Enable PCX Backend Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the PCX (ZSoft PCX) image format backend for SDL Image. This is controlled by the SDLIMAGE_PCX CMake variable. ```cmake 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() ``` -------------------------------- ### Support Loading QOI Images Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables support for loading QOI (Quite OK Image format) image files. ```cmake option(SDLIMAGE_QOI "Support loading QOI images" ON) ``` -------------------------------- ### Configure JPG Backend and Shared Library Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets whether the JPG backend is vendored and configures the option for dynamically loading JPG support, which requires a shared libjpeg. ```cmake 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(SDLIMAGE_JPG_VENDORED OFF) endif() 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) ``` -------------------------------- ### Configure WEBP Backend and Shared Library Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets whether the WEBP backend is vendored and configures the option for dynamically loading WEBP support, which requires a shared libwebp. ```cmake if(SDLIMAGE_VENDORED AND SDLIMAGE_WEBP) set(SDLIMAGE_WEBP_VENDORED ON) else() set(SDLIMAGE_WEBP_VENDORED OFF) endif() cmake_dependent_option(SDLIMAGE_WEBP_SHARED "Dynamically load WEBP support (requires shared libwebp)" ${SDLIMAGE_DEPS_SHARED} SDLIMAGE_WEBP OFF) ``` -------------------------------- ### Find System libjxl Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Attempts to find and use a system-installed libjxl. If found, it enables JXL support and configures include directories. If not found, it reports a fatal error. ```cmake find_package(libjxl ${required}) if(libjxl_FOUND) message(STATUS "${PROJECT_NAME}: Using system libjxl") 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() else() message(${fatal_error} "libjxl NOT found") endif() target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_JXL) if(SDLIMAGE_JXL_SHARED) if(NOT DEFINED SDLIMAGE_DYNAMIC_JXL) target_include_directories(${sdl3_image_target_name} PRIVATE $ ``` -------------------------------- ### Tagging a Release Source: https://github.com/libsdl-org/sdl_image/blob/main/docs/release_checklist.md Tag the release using git and push the tags to the repository. Replace 'release-3.8.0' with the actual release tag. ```bash git tag release-3.8.0; git push --tags ``` -------------------------------- ### Configure SDL_image Build with CMake Source: https://github.com/libsdl-org/sdl_image/blob/main/cmake/test/CMakeLists.txt Sets up the CMake build environment for SDL_image, specifying the minimum required CMake version and project language. It also configures search paths and feature options. ```cmake cmake_minimum_required(VERSION 3.12...3.28) project(sdl_test LANGUAGES C) cmake_policy(SET CMP0074 NEW) # Override CMAKE_FIND_ROOT_PATH_MODE to allow search for SDL3 outside of sysroot set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER) include(FeatureSummary) option(TEST_SHARED "Test linking to shared SDL3_image library" ON) add_feature_info("TEST_SHARED" TEST_SHARED "Test linking with shared library") option(TEST_STATIC "Test linking to static SDL3_image library" ON) add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library") ``` -------------------------------- ### Configure Dynamic libpng Loading Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets up dynamic loading for the libpng library. This involves determining the target for libpng and retrieving its dynamic library name. ```cmake if(SDLIMAGE_PNG_SHARED) if(NOT DEFINED SDLIMAGE_DYNAMIC_PNG) if(TARGET PNG::png_shared) set(png_target PNG::png_shared) else() set(png_target PNG::PNG) endif() target_include_directories(${sdl3_image_target_name} PRIVATE $ ) if(SDLIMAGE_PNG_VENDORED) add_dependencies(${sdl3_image_target_name} ${png_target}) endif() else() # target_get_dynamic_library will ignore target set(png_target dont_care) endif() target_get_dynamic_library(SDLIMAGE_DYNAMIC_PNG ${png_target}) message(STATUS "Dynamic libpng: ${SDLIMAGE_DYNAMIC_PNG}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_LIBPNG_DYNAMIC=\"${SDLIMAGE_DYNAMIC_PNG}\"") ``` -------------------------------- ### Configure JXL Backend with Dynamic Loading Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the JXL backend and configures dynamic loading of the libjxl library. This is used when SDLIMAGE_JXL is enabled and dynamic loading of libjxl is preferred. ```cmake target_get_dynamic_library(SDLIMAGE_DYNAMIC_JXL libjxl::libjxl) message(STATUS "Dynamic libjxl: ${SDLIMAGE_DYNAMIC_JXL}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_JXL_DYNAMIC=\"${SDLIMAGE_DYNAMIC_JXL}\"") ``` -------------------------------- ### Manage Backend Dependencies Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Iterates through defined SDLIMAGE_BACKENDS to determine and report enabled and disabled dependencies. ```cmake set(available_deps) set(unavailable_deps) foreach(dep IN LISTS SDLIMAGE_BACKENDS) set(var SDLIMAGE_${dep}_ENABLED) if(NOT DEFINED ${var}) message(AUTHOR_WARNING "${var} not defined") endif() if(${var}) list(APPEND available_deps ${dep}) else() list(APPEND unavailable_deps ${dep}) endif() endforeach() string(JOIN " " avail_str ${available_deps}) string(TOLOWER "${avail_str}" avail_str) string(JOIN " " unavail_str ${unavailable_deps}) string(TOLOWER "${unavail_str}" unavail_str) message(STATUS "SDL3_image backends:") message(STATUS "- enabled: ${avail_str}") message(STATUS "- disabled: ${unavail_str}") ``` -------------------------------- ### Configure PNG Backend and Shared Library Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets whether the PNG backend is vendored and configures the option for dynamically loading PNG support, which requires a shared libpng. ```cmake if(SDLIMAGE_VENDORED AND SDLIMAGE_PNG) set(SDLIMAGE_PNG_VENDORED ON) else() set(SDLIMAGE_PNG_VENDORED OFF) endif() cmake_dependent_option(SDLIMAGE_PNG_SHARED "Dynamically load PNG support (requires shared libpng)" ${SDLIMAGE_DEPS_SHARED} "SDLIMAGE_PNG" OFF) ``` -------------------------------- ### Enable XCF Backend Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the XCF image format backend by adding it to the list of supported backends and defining LOAD_XCF. ```cmake list(APPEND SDLIMAGE_BACKENDS XCF) set(SDLIMAGE_XCF_ENABLED TRUE) if(SDLIMAGE_XCF) set(SDLIMAGE_XCF_ENABLED TRUE) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_XCF) endif() ``` -------------------------------- ### CMakeLists.txt for SDL_image Project Source: https://github.com/libsdl-org/sdl_image/blob/main/docs/INTRO-cmake.md Configure your CMake project to include SDL and SDL_image as subprojects. Ensure the SDL and SDL_image source directories are correctly placed. ```cmake cmake_minimum_required(VERSION 3.16) project(hello) # set the output directory for built objects. # This makes sure that the dynamic library goes into the build directory automatically. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$") # This assumes the SDL source is available in vendored/SDL add_subdirectory(vendored/SDL EXCLUDE_FROM_ALL) # This assumes the SDL_image source is available in vendored/SDL_image add_subdirectory(vendored/SDL_image EXCLUDE_FROM_ALL) # Create your game executable target as usual add_executable(hello WIN32 hello.c) # Link to the actual SDL3 library. target_link_libraries(hello PRIVATE SDL3_image::SDL3_image SDL3::SDL3) ``` -------------------------------- ### CMakeLists.txt Configuration for SDL_image and Emscripten Source: https://github.com/libsdl-org/sdl_image/blob/main/docs/INTRO-emscripten.md Configure CMake to include SDL and SDL_image as subprojects and set Emscripten-specific output suffixes. Ensure SDL sources are in 'vendored/SDL' and SDL_image sources are in 'vendored/SDL_image'. ```cmake cmake_minimum_required(VERSION 3.16) project(hello) # set the output directory for built objects. # This makes sure that the dynamic library goes into the build directory automatically. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$") # This assumes the SDL source is available in vendored/SDL add_subdirectory(vendored/SDL EXCLUDE_FROM_ALL) # This assumes the SDL_image source is available in vendored/SDL_image add_subdirectory(vendored/SDL_image EXCLUDE_FROM_ALL) # on Web targets, we need CMake to generate a HTML webpage. if(EMSCRIPTEN) set(CMAKE_EXECUTABLE_SUFFIX ".html" CACHE INTERNAL "") endif() # Create your game executable target as usual add_executable(hello WIN32 hello.c) # Link to the actual SDL3 library. target_link_libraries(hello PRIVATE SDL3_image::SDL3_image SDL3::SDL3) ``` -------------------------------- ### Link JXL Backend Statically Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Links the libjxl library statically to the SDL3_image target. This is the default behavior when dynamic loading is not explicitly configured. ```cmake target_link_libraries(${sdl3_image_target_name} PRIVATE libjxl::libjxl) ``` -------------------------------- ### Configure JPEG Dynamic Library Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets up dynamic linking for the JPEG library. It checks if JPEG is vendored and adds dependencies accordingly. The status of the dynamic libjpeg is printed to the console. ```cmake target_get_dynamic_library(SDLIMAGE_DYNAMIC_JPEG JPEG::JPEG) message(STATUS "Dynamic libjpeg: ${SDLIMAGE_DYNAMIC_JPEG}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_JPG_DYNAMIC=\"${SDLIMAGE_DYNAMIC_JPEG}\"") ``` -------------------------------- ### Enable GIF Support in SDL3_image Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Configures compile definitions for GIF support in SDL3_image. Use LOAD_GIF to enable decoding and SAVE_GIF to enable encoding. ```cmake target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_GIF SAVE_GIF=$ ) ``` -------------------------------- ### Enable AVIF Support in SDL3_image Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Configures compile definitions for AVIF support in SDL3_image. Use LOAD_AVIF to enable decoding and SAVE_AVIF to enable encoding. ```cmake target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_AVIF SAVE_AVIF=$ ) ``` -------------------------------- ### Enable LBM Backend Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the LBM (Lightweight Bitmap) image format backend for SDL Image. This is controlled by the SDLIMAGE_LBM CMake variable. ```cmake 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() ``` -------------------------------- ### Enable WEBP Support Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables WEBP support by defining necessary compile definitions, including whether WEBP saving is enabled. ```cmake if(SDLIMAGE_WEBP_ENABLED) target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_WEBP SAVE_WEBP=$ ) if(SDLIMAGE_WEBP_SHARED) ``` -------------------------------- ### Add Uninstall Target Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Configures an uninstall target by generating a cmake_uninstall.cmake script from a template. ```cmake configure_file(cmake/cmake_uninstall.cmake.in cmake_uninstall.cmake IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") ``` -------------------------------- ### Generate Manpages Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Generates manpages for SDL Image, requiring a Git revision hash and specific paths for headers and wiki headers. ```cmake 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 "${SDLIMAGE_REVISION}" ) ``` -------------------------------- ### Define Resource Files for Tests Source: https://github.com/libsdl-org/sdl_image/blob/main/test/CMakeLists.txt Lists various image file formats used as resources for SDL_image tests. These files are copied to the build directory for use by test executables. ```cmake set(RESOURCE_FILES palette.bmp palette.gif rgbrgb.ani rgbrgb.avifs rgbrgb.gif rgbrgb.png rgbrgb_thirdpartymetadata.webp rgbrgb.webp sample.avif sample.bmp sample.cur sample.ico sample.jpg sample.jxl sample.pcx sample.png sample.pnm sample.qoi sample.tga sample.tif sample.webp sample.xcf sample.xpm svg-class.bmp svg-class.svg svg.bmp svg.svg svg64.bmp ) ``` -------------------------------- ### Enable STB Image Backend Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the STB Image backend for SDL_image. This is typically used when SDLIMAGE_BACKEND_STB is defined. ```cmake 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() ``` -------------------------------- ### Link WebP Libraries Statically Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Links the WebP, WebPdemux, and libwebpmux libraries statically to the target. This is an alternative to dynamic loading. ```cmake target_link_libraries(${sdl3_image_target_name} PRIVATE WebP::webp WebP::webpdemux WebP::libwebpmux) ``` -------------------------------- ### Link Static SDL3_image Library Source: https://github.com/libsdl-org/sdl_image/blob/main/cmake/test/CMakeLists.txt Configures the build to link against a static SDL3_image library. This requires enabling C++ support and linking the executable against the static targets of SDL3 and SDL3_image. ```cmake if(TEST_STATIC) find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3) # some static vendored libraries use c++ (enable CXX after `find_package` might show a warning) enable_language(CXX) find_package(SDL3_image REQUIRED CONFIG) add_executable(main_static main.c) target_link_libraries(main_static PRIVATE SDL3_image::SDL3_image-static SDL3::SDL3) endif() ``` -------------------------------- ### Build Unit Tests Option Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables the building of unit tests for SDL3_image. ```cmake option(SDLIMAGE_TESTS "Build unit tests?" OFF) ``` -------------------------------- ### Fail on Missing Dependencies Option Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Configures whether the build should fail if a dependency cannot be found. Defaults to 'STATUS' (non-fatal), but changes to 'FATAL_ERROR' if strict mode is enabled. ```cmake option(SDLIMAGE_STRICT "Fail when a dependency could not be found" OFF) set(required "") set(fatal_error "STATUS") if(SDLIMAGE_STRICT) set(required "REQUIRED") set(fatal_error "FATAL_ERROR") endif() ``` -------------------------------- ### Dry Run Release Asset Creation Source: https://github.com/libsdl-org/sdl_image/blob/main/docs/release_checklist.md Execute this script for a dry run to create release assets and verify archives. Replace with the relevant branch name. ```bash build-scripts/create-release.py -R libsdl-org/SDL_image --ref ``` -------------------------------- ### Dynamically Load AVIF Dependencies Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Configures whether to dynamically load AVIF support libraries (libdav1d, libaom). Enabled if dynamic loading is generally enabled and AVIF support is active. ```cmake if(SDLIMAGE_AVIF_SHARED) set(SDLIMAGE_DAV1D_SHARED ON) set(SDLIMAGE_AOM_SHARED ON) else() set(SDLIMAGE_DAV1D_SHARED OFF) set(SDLIMAGE_AOM_SHARED OFF) endif() ``` -------------------------------- ### Configure JXL Backend and Shared Library Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets whether the JXL backend is vendored and configures the option for dynamically loading JXL support, which requires a shared libjxl. ```cmake if(SDLIMAGE_VENDORED AND SDLIMAGE_JXL) set(SDLIMAGE_JXL_VENDORED ON) else() set(SDLIMAGE_JXL_VENDORED OFF) endif() cmake_dependent_option(SDLIMAGE_JXL_SHARED "Dynamically load JXL support (requires shared libjxl)" ${SDLIMAGE_DEPS_SHARED} SDLIMAGE_JXL OFF) ``` -------------------------------- ### Support Loading WEBP Images Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables support for loading WEBP image files. ```cmake option(SDLIMAGE_WEBP "Support loading WEBP images" ON) ``` -------------------------------- ### Support Loading XV Images Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables support for loading XV (John Bradley's image viewer) image files. ```cmake option(SDLIMAGE_XV "Support loading XV images" ON) ``` -------------------------------- ### Use libjxl from CMake Variable Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Configures SDL Image to use libjxl specified by a CMake variable. This is an alternative to using a vendored or system-found libjxl. ```cmake message(STATUS "${PROJECT_NAME}: Using libjxl from CMake variable") set(SDLIMAGE_JXL_ENABLED TRUE) ``` -------------------------------- ### Configure Vendored libjxl Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables the use of a vendored libjxl. It configures various build options for libjxl, such as disabling benchmarks, JNI, and manpages, and sets up the build for shared or static libraries. ```cmake set(SDLIMAGE_JXL_ENABLED TRUE) enable_language(CXX) message(STATUS "${PROJECT_NAME}: Using vendored libjxl") # BUILD_TESTING variable is used by libjxl set(BUILD_TESTING OFF CACHE BOOL "build testing") # JPEGXL_ENABLE_BENCHMARK variable is used by libjxl set(JPEGXL_ENABLE_BENCHMARK OFF CACHE BOOL "libjpegxl benchmark" FORCE) # JPEGXL_ENABLE_TOOLS variable is used by libjxl set(JPEGXL_ENABLE_JNI OFF CACHE BOOL "build jpegxl jni" FORCE) # JPEGXL_ENABLE_SJPEG variable is used by libjxl set(JPEGXL_ENABLE_SJPEG OFF CACHE BOOL "build jpegxl sjpeg" FORCE) # JPEGXL_BUNDLE_SKCMS variable is used by libjxl set(JPEGXL_BUNDLE_SKCMS OFF CACHE BOOL "build jpegxl bundle sjpeg" FORCE) # JPEGXL_ENABLE_OPENEXR variable is used by libjxl set(JPEGXL_ENABLE_OPENEXR OFF CACHE BOOL "build jpegxl openxr" FORCE) # JPEGXL_ENABLE_MANPAGES variable is used by libjxl set(JPEGXL_ENABLE_MANPAGES OFF CACHE BOOL "libjxl manpage option" FORCE) # JPEGXL_ENABLE_PLUGINS variable is used by libjxl set(JPEGXL_ENABLE_PLUGINS OFF CACHE BOOL "libjxl manpage option" FORCE) # JPEGXL_ENABLE_SKCMS variable is used by libjxl 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 SDLIMAGE_VENDORED) set(BUILD_SHARED_LIBS ${SDLIMAGE_JXL_SHARED}) add_subdirectory(external/libjxl external/libjxl-build EXCLUDE_FROM_ALL) register_license(jxl external/libjxl/LICENSE) if(SDLIMAGE_JXL_SHARED) set(jxl_lib jxl) set(jxl_install_libs brotlidec brotlicommon brotlienc jxl) else() set(jxl_lib jxl_dec-static) set(jxl_install_libs brotlidec brotlicommon hwy jxl_dec-static) list(APPEND PC_LIBS -l$ -l$ -l$ -l$ ) endif() 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) add_library(SDL3_image::external_libjxl ALIAS ${jxl_lib}) if(NOT TARGET libjxl::libjxl) add_library(libjxl::libjxl ALIAS ${jxl_lib}) endif() ``` -------------------------------- ### Support Loading AVIF Images Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables support for loading AVIF image files. ```cmake option(SDLIMAGE_AVIF "Support loading AVIF images" ON) ``` -------------------------------- ### Enable ANI Support in SDL3_image Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Configures compile definitions for ANI support in SDL3_image. Use LOAD_ANI to enable decoding and SAVE_ANI to enable encoding. ```cmake target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_ANI SAVE_ANI=$ ) ``` -------------------------------- ### Configure Dynamic AVIF Library Path Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets the dynamic library path for AVIF when building a shared SDL3_image. This is used to locate the AVIF library at runtime. ```cmake target_get_dynamic_library(SDLIMAGE_DYNAMIC_AVIF avif) message(STATUS "Dynamic libavif: ${SDLIMAGE_DYNAMIC_AVIF}") target_compile_definitions(${sdl3_image_target_name} PRIVATE "LOAD_AVIF_DYNAMIC=\"${SDLIMAGE_DYNAMIC_AVIF}\"") ``` -------------------------------- ### Configure TIFF Backend and Shared Library Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Sets whether the TIFF backend is vendored and configures the option for dynamically loading TIFF support, which requires a shared libtiff. ```cmake if(SDLIMAGE_VENDORED AND SDLIMAGE_TIF AND NOT (SDLIMAGE_BACKEND_IMAGEIO OR SDLIMAGE_BACKEND_WIC)) set(SDLIMAGE_TIF_VENDORED ON) else() set(SDLIMAGE_TIF_VENDORED OFF) endif() cmake_dependent_option(SDLIMAGE_TIF_SHARED "Dynamically load TIFF support (requires shared libtiff)" ${SDLIMAGE_DEPS_SHARED} SDLIMAGE_TIF OFF) ``` -------------------------------- ### Support Loading PCX Images Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables support for loading PCX image files. ```cmake option(SDLIMAGE_PCX "Support loading PCX images" ON) ``` -------------------------------- ### Update Windows Resource Version (src/version.rc) Source: https://github.com/libsdl-org/sdl_image/blob/main/docs/release_checklist.md Update the file and product versions in the src/version.rc file for Windows executables. ```rc FILEVERSION 3,3,0,0 PRODUCTVERSION 3,3,0,0 FileVersion "3.3.0.0" ProductVersion "3.3.0.0" ``` -------------------------------- ### Support PNG with libpng (APNG) Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables the use of libpng for loading PNG files, which is useful for supporting APNG (Animated PNG) files. ```cmake cmake_dependent_option(SDLIMAGE_PNG_LIBPNG "Support loading PNGs using libpng (useful for APNGs)" ON SDLIMAGE_PNG OFF) ``` -------------------------------- ### Enable STB Image Backend Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables the use of the stb_image library for loading JPEG files. ```cmake option(SDLIMAGE_BACKEND_STB "Use stb_image for loading JPEG files" ON) ``` -------------------------------- ### Enable BMP Support in SDL3_image Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Configures compile definitions for BMP support in SDL3_image. Use LOAD_BMP to enable decoding and SAVE_BMP to enable encoding. ```cmake target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_BMP SAVE_BMP=$ ) ``` -------------------------------- ### Copy Test Resource Files Source: https://github.com/libsdl-org/sdl_image/blob/main/test/CMakeLists.txt Defines a custom command to copy resource files to the build directory and a custom target to depend on this copy operation. This ensures test resources are available during the build. ```cmake set(RESOURCE_FILES_BIN_ABS ) foreach(res_file_name IN LISTS RESOURCE_FILES) set(resource_file "${CMAKE_CURRENT_SOURCE_DIR}/${res_file_name}") set(resource_file_bindir "${CMAKE_CURRENT_BINARY_DIR}/${res_file_name}") add_custom_command( OUTPUT "${resource_file_bindir}" DEPENDS "${resource_file}" COMMAND "${CMAKE_COMMAND}" -E copy "${resource_file}" "${resource_file_bindir}" ) list(APPEND RESOURCE_FILES_BIN_ABS "${resource_file_bindir}") endforeach() add_custom_target(copy-sdl_image-test-resources DEPENDS "${RESOURCE_FILES_BIN_ABS}") ``` -------------------------------- ### Support Loading XCF Images Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables support for loading XCF (GIMP) image files. ```cmake option(SDLIMAGE_XCF "Support loading XCF images" ON) ``` -------------------------------- ### Support Loading GIF Images Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables support for loading GIF image files. ```cmake option(SDLIMAGE_GIF "Support loading GIF images" ON) ``` -------------------------------- ### Dynamically Load Dependencies Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Configures whether to load dependencies dynamically. Enabled by default when shared libraries are supported. ```cmake cmake_dependent_option(SDLIMAGE_DEPS_SHARED "Load dependencies dynamically" ON PLATFORM_SUPPORTS_SHARED OFF) ``` -------------------------------- ### Add WEBP Save Support Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables the ability to save images in WEBP format. Dependent on WEBP support being enabled. ```cmake cmake_dependent_option(SDLIMAGE_WEBP_SAVE "Add WEBP save support" ON SDLIMAGE_WEBP OFF) ``` -------------------------------- ### Build Shared Libraries Option Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables building the library as a shared library, dependent on platform support. ```cmake cmake_dependent_option(BUILD_SHARED_LIBS "Build the library as a shared library" ON PLATFORM_SUPPORTS_SHARED OFF) ``` -------------------------------- ### Enable JPEG Support Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables JPEG support by defining necessary preprocessor macros. It also sets a variable for saving JPEG, which is used by the test suite. ```cmake target_compile_definitions(${sdl3_image_target_name} PRIVATE LOAD_JPG SAVE_JPG=$) else() # Variable is used by test suite set(SDLIMAGE_JPG_SAVE OFF) endif() ``` -------------------------------- ### Support Loading LBM Images Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables support for loading LBM (Deluxe Paint) image files. ```cmake option(SDLIMAGE_LBM "Support loading LBM images" ON) ``` -------------------------------- ### Support Loading XPM Images Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables support for loading XPM (X PixMap) image files. ```cmake option(SDLIMAGE_XPM "Support loading XPM images" ON) ``` -------------------------------- ### Support Loading PNG Images Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables support for loading PNG image files. ```cmake option(SDLIMAGE_PNG "Support loading PNG images" ON) ``` -------------------------------- ### Generate Feature Summary Source: https://github.com/libsdl-org/sdl_image/blob/main/cmake/test/CMakeLists.txt Generates a summary of all configured features. This is typically used at the end of a CMake script to report the build configuration. ```cmake feature_summary(WHAT ALL) ``` -------------------------------- ### Add Test Executables and Tests Source: https://github.com/libsdl-org/sdl_image/blob/main/test/CMakeLists.txt Adds specific test executables and their corresponding test cases using the previously defined functions. This includes 'testimage' and 'testanimation'. ```cmake add_sdl_image_test_executable(testimage SOURCES testimage.c RESOURCES) add_sdl_image_test_executable(testanimation SOURCES testanimation.c RESOURCES) add_sdl_image_test(testimage COMMAND testimage) add_sdl_image_test(testanimation_dummy_metadata COMMAND testanimation) ``` -------------------------------- ### Support Loading PNM Images Source: https://github.com/libsdl-org/sdl_image/blob/main/CMakeLists.txt Enables or disables support for loading PNM (Portable Anymap) image files. ```cmake option(SDLIMAGE_PNM "Support loading PNM images" ON) ``` -------------------------------- ### Add SDL_image Test Source: https://github.com/libsdl-org/sdl_image/blob/main/test/CMakeLists.txt Adds a test executable to the build system. Use this to define new tests for SDL_image. ```cmake add_sdl_image_test(testanimation COMMAND testanimation --no-dummy-metadata) ```