diff --git a/.github/workflows/ci-linux-golden-tests.yml b/.github/workflows/ci-linux-golden-tests.yml index 21e32dd5af..69f55cfd72 100644 --- a/.github/workflows/ci-linux-golden-tests.yml +++ b/.github/workflows/ci-linux-golden-tests.yml @@ -63,7 +63,7 @@ jobs: -DAVIF_CODEC_AOM=LOCAL -DAVIF_LIBYUV=LOCAL -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON -DAVIF_ENABLE_EXPERIMENTAL_GAIN_MAP=ON - -DAVIF_LOCAL_LIBXML2=ON + -DAVIF_LIBXML2=LOCAL -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GOLDEN_TESTS=ON -DAVIF_ENABLE_GTEST=OFF -DAVIF_ENABLE_WERROR=ON -DGOLDEN_TESTS_OUTPUT_DIR=${{ runner.temp }}/golden_tests diff --git a/.github/workflows/ci-linux-static-old-local.yml b/.github/workflows/ci-linux-static-old-local.yml new file mode 100644 index 0000000000..a188e0b776 --- /dev/null +++ b/.github/workflows/ci-linux-static-old-local.yml @@ -0,0 +1,95 @@ +name: CI Unix Static For AVIF_LOCAL +on: [push, pull_request] + +permissions: + contents: read + +# Cancel the workflow if a new one is triggered from the same PR, branch, or tag, except on main. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + build-static: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + build-type: [Release, Debug] + include: + - runs-on: ubuntu-latest + compiler: gcc + gcc: 13 + + steps: + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - name: Set GCC & G++ compiler (on Linux) + run: echo "CC=gcc-${{matrix.gcc}}" >> $GITHUB_ENV && echo "CXX=g++-${{matrix.gcc}}" >> $GITHUB_ENV + - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: '3.x' + - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 + with: + profile: minimal + toolchain: stable + override: true + - name: Install cargo-c (linux) + env: + LINK: https://github.com/lu-zero/cargo-c/releases/latest/download + CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz + run: | + curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@959f1116cf9f1ae42fff8ec1a4aaae6d4a0e348b # v2.0.1 + with: + # CMake version 3.18 is required to build libxml2. + cmake-version: '3.18.x' + - name: Print cmake version + run: cmake --version + - uses: ilammy/setup-nasm@13cbeb366c45c4379d3478cdcbadd8295feb5028 # v1.5.1 + - uses: seanmiddleditch/gha-setup-ninja@8b297075da4cd2a5f1fd21fe011b499edf06e9d2 # v4 + - run: pip install meson + - name: Print ImageMagick version + run: convert --version + - name: Prepare libavif (cmake) + run: > + mkdir build && cd build + + cmake .. -G Ninja + -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DBUILD_SHARED_LIBS=OFF + -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON + -DAVIF_CODEC_DAV1D=ON -DAVIF_LOCAL_DAV1D=ON + -DAVIF_CODEC_RAV1E=ON -DAVIF_LOCAL_RAV1E=ON + -DAVIF_CODEC_SVT=ON -DAVIF_LOCAL_SVT=ON + -DAVIF_CODEC_LIBGAV1=ON -DAVIF_LOCAL_LIBGAV1=ON + -DAVIF_LOCAL_LIBSHARPYUV=ON -DAVIF_LOCAL_LIBXML2=ON -DAVIF_LOCAL_LIBYUV=ON + -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON + -DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON + -DAVIF_ENABLE_EXPERIMENTAL_GAIN_MAP=ON + -DAVIF_ENABLE_EXPERIMENTAL_AVIR=ON + -DAVIF_ENABLE_WERROR=ON + - name: Cache cargo registry + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + continue-on-error: true + with: + path: ~/.cargo/registry/cache + key: cargo-registry-${{ runner.os }}-${{ hashFiles('ext/rav1e/Cargo.lock') }}-unix-static + restore-keys: | + cargo-registry-${{ runner.os }}-${{ hashFiles('ext/rav1e/Cargo.lock') }}- + cargo-registry-${{ runner.os }}- + - name: Build libavif (ninja) + working-directory: ./build + run: ninja + - name: Run AVIF Tests + working-directory: ./build + run: ctest -j $(getconf _NPROCESSORS_ONLN) --output-on-failure + - name: Check static link bundling + run: | + cc -o avifenc -I./apps/shared -I./third_party/iccjpeg -I./include apps/avifenc.c \ + apps/shared/*.c third_party/iccjpeg/iccjpeg.c build/libavif.a \ + -lpng -ljpeg -lz -lm -ldl -lstdc++ + + ./avifenc --help diff --git a/.github/workflows/ci-mingw.yml b/.github/workflows/ci-mingw.yml index ef55fa4ddf..bcc24bfb47 100644 --- a/.github/workflows/ci-mingw.yml +++ b/.github/workflows/ci-mingw.yml @@ -60,7 +60,7 @@ jobs: -DAVIF_CODEC_DAV1D=SYSTEM -DAVIF_LIBSHARPYUV=LOCAL -DAVIF_LIBYUV=SYSTEM -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON - -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL -DAVIF_BUILD_GDK_PIXBUF=ON -DCMAKE_INSTALL_PREFIX=./install -DAVIF_ENABLE_WERROR=ON - name: Build libavif (ninja) diff --git a/.github/workflows/ci-unix-shared-installed.yml b/.github/workflows/ci-unix-shared-installed.yml index 3dace5243e..df727f9bf3 100644 --- a/.github/workflows/ci-unix-shared-installed.yml +++ b/.github/workflows/ci-unix-shared-installed.yml @@ -65,7 +65,7 @@ jobs: -DAVIF_CODEC_AOM_DECODE=OFF -DAVIF_CODEC_AOM_ENCODE=ON -DAVIF_CODEC_DAV1D=SYSTEM -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON - -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL -DAVIF_BUILD_GDK_PIXBUF=ON -DCMAKE_INSTALL_PREFIX=./install -DAVIF_ENABLE_WERROR=ON ${{ env.CMAKE_AVIF_FLAGS }} - name: Build libavif (ninja) @@ -104,7 +104,7 @@ jobs: -DAVIF_CODEC_DAV1D=SYSTEM -DAVIF_ENABLE_WUNUSED_RESULT=ON -DAVIF_ENABLE_WERROR=ON -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON - -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL -DAVIF_BUILD_GDK_PIXBUF=ON ${{ env.CMAKE_AVIF_FLAGS }} -DCMAKE_INSTALL_PREFIX=./install - name: Build libavif with [[nodiscard]] (ninja) diff --git a/.github/workflows/ci-unix-shared-local.yml b/.github/workflows/ci-unix-shared-local.yml index 7bfed13662..213029139b 100644 --- a/.github/workflows/ci-unix-shared-local.yml +++ b/.github/workflows/ci-unix-shared-local.yml @@ -60,7 +60,7 @@ jobs: -DAVIF_LIBYUV=${{ matrix.libyuv }} -DAVIF_LIBSHARPYUV=LOCAL -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON - -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL -DAVIF_ENABLE_WERROR=ON - name: Build libavif (ninja) working-directory: ./build diff --git a/.github/workflows/ci-unix-static-av2.yml b/.github/workflows/ci-unix-static-av2.yml index 93331e8512..534fdc8d3d 100644 --- a/.github/workflows/ci-unix-static-av2.yml +++ b/.github/workflows/ci-unix-static-av2.yml @@ -65,7 +65,7 @@ jobs: -DAVIF_LIBYUV=LOCAL -DAVIF_LIBSHARPYUV=LOCAL -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON - -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL -DAVIF_ENABLE_WERROR=ON - name: Cache cargo registry uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/ci-unix-static-sanitized.yml b/.github/workflows/ci-unix-static-sanitized.yml index 4fc9c92d15..aad41d19dd 100644 --- a/.github/workflows/ci-unix-static-sanitized.yml +++ b/.github/workflows/ci-unix-static-sanitized.yml @@ -79,7 +79,7 @@ jobs: -DAVIF_CODEC_AOM=LOCAL -DAVIF_CODEC_DAV1D=LOCAL -DAVIF_LIBYUV=LOCAL -DAVIF_LIBSHARPYUV=LOCAL -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON - -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL env: CFLAGS: -fsanitize=${{ matrix.sanitizer }} CXXFLAGS: -fsanitize=${{ matrix.sanitizer }} diff --git a/.github/workflows/ci-unix-static.yml b/.github/workflows/ci-unix-static.yml index 62c96c87a3..c02b66960f 100644 --- a/.github/workflows/ci-unix-static.yml +++ b/.github/workflows/ci-unix-static.yml @@ -55,8 +55,8 @@ jobs: - name: Setup cmake uses: jwlawson/actions-setup-cmake@959f1116cf9f1ae42fff8ec1a4aaae6d4a0e348b # v2.0.1 with: - # CMake version 3.17 is required to build libwebp (which libsharpyuv is part of) on macOS. - cmake-version: '3.17.x' + # CMake version 3.18 is required to build libxml2. + cmake-version: '3.18.x' - name: Print cmake version run: cmake --version - uses: ilammy/setup-nasm@13cbeb366c45c4379d3478cdcbadd8295feb5028 # v1.5.1 @@ -72,10 +72,10 @@ jobs: -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=LOCAL -DAVIF_CODEC_DAV1D=LOCAL -DAVIF_CODEC_RAV1E=LOCAL -DAVIF_CODEC_SVT=LOCAL - -DAVIF_CODEC_LIBGAV1=LOCAL -DAVIF_LIBYUV=LOCAL - -DAVIF_LIBSHARPYUV=LOCAL + -DAVIF_CODEC_LIBGAV1=LOCAL + -DAVIF_LIBSHARPYUV=LOCAL -DAVIF_LIBXML2=LOCAL -DAVIF_LIBYUV=LOCAL -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON - -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL -DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON -DAVIF_ENABLE_EXPERIMENTAL_GAIN_MAP=ON -DAVIF_ENABLE_EXPERIMENTAL_AVIR=ON diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 019888cf39..42a409e711 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -7,8 +7,8 @@ # https://gitlab.kitware.com/cmake/cmake/-/issues/20585 # * Runs ext/*.cmd as Windows batch files rather than using bash. This is # important for ext/svt.cmd, to prevent it from running ext/svt.sh. -# * Builds with local libjpeg (-DAVIF_LOCAL_JPEG=ON). -# * Builds with local zlib and libpng (-DAVIF_LOCAL_ZLIBPNG=ON). +# * Builds with local libjpeg (-DAVIF_JPEG=LOCAL). +# * Builds with local zlib and libpng (-DAVIF_ZLIBPNG=LOCAL). name: CI Windows on: [push, pull_request] @@ -90,11 +90,11 @@ jobs: -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=LOCAL -DAVIF_CODEC_DAV1D=LOCAL -DAVIF_CODEC_RAV1E=LOCAL -DAVIF_CODEC_SVT=LOCAL - -DAVIF_CODEC_LIBGAV1=LOCAL -DAVIF_LIBYUV=LOCAL - -DAVIF_LOCAL_JPEG=ON -DAVIF_LIBSHARPYUV=LOCAL - -DAVIF_LOCAL_ZLIBPNG=ON + -DAVIF_CODEC_LIBGAV1=LOCAL + -DAVIF_JPEG=LOCAL -DAVIF_LIBSHARPYUV=LOCAL -DAVIF_LIBXML2=LOCAL + -DAVIF_LIBYUV=LOCAL -DAVIF_ZLIBPNG=LOCAL -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON - -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL -DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON -DAVIF_ENABLE_EXPERIMENTAL_GAIN_MAP=ON -DAVIF_ENABLE_EXPERIMENTAL_AVIR=ON -DAVIF_ENABLE_WERROR=ON diff --git a/CHANGELOG.md b/CHANGELOG.md index 64f0995698..d0c56658d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,8 +78,9 @@ The changes are relative to the previous release, unless the baseline is specifi crbug.com/1504792 by [Fudan University](https://secsys.fudan.edu.cn/). * For codecs, AVIF_CODEC_* and AVIF_LOCAL_* are now merged into AVIF_CODEC_* that can only take the values: OFF, LOCAL or SYSTEM. -* For the libyuv, libsharpyuv, zlibpng and jpeg dependencies, AVIF_LOCAL_* is - now replaced by flags AVIF_* that can take the values: OFF, LOCAL or SYSTEM. +* For the gtest, jpeg, libsharpyuv, libxml2, libyuv and zlibpng dependencies, + AVIF_LOCAL_* is now replaced by flags AVIF_* that can take the values: + OFF, LOCAL or SYSTEM. * src/reformat.c: Allocate the threadData array directly. * AVIF_ENABLE_WERROR is set to OFF by default. * Fix wrong alpha plane deallocation when decoded tile pixel format does not diff --git a/CMakeLists.txt b/CMakeLists.txt index da5b8c8b3b..b2aaf7080e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,7 @@ function(set_local_or_system_option VAR DEFAULT TEXT) else() set(DEFAULT "SYSTEM") endif() + message(WARNING "Setting AVIF_LOCAL_${VAR} is deprecated. " "Set AVIF_${VAR} to ${DEFAULT} instead.") elseif(DEFINED AVIF_${VAR}) set(DEFAULT ${AVIF_${VAR}}) endif() @@ -110,8 +111,9 @@ cmake_dependent_option( AVIF_CODEC_AOM_ENCODE "if AVIF_CODEC_AOM is on, use/offer libaom's encoder" ON "NOT AVIF_CODEC_AOM STREQUAL OFF" OFF ) -option(AVIF_LOCAL_GTEST - "Build the GoogleTest framework by providing your own copy of the repo in ext/googletest (see Local Builds in README)" OFF +set_local_or_system_option( + "GTEST" OFF + "Build the GoogleTest framework by providing your own copy of the repo in ext/googletest (see Local Builds in README)" ) option(AVIF_LOCAL_FUZZTEST "Build the Google FuzzTest framework by providing your own copy of the repo in ext/fuzztest (see Local Builds in README)" @@ -248,17 +250,13 @@ if(AVIF_LIBSHARPYUV_ENABLED) avif_target_link_library(sharpyuv::sharpyuv) endif(AVIF_LIBSHARPYUV_ENABLED) -option(AVIF_LOCAL_LIBXML2 "Build libxml2 by providing your own copy inside the ext subdir. \ -libxml2 is used when AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP is ON" OFF +set_local_or_system_option( + "LIBXML2" "OFF" "Build libxml2 by providing your own copy inside the ext subdir. \ +libxml2 is used when AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP is ON" ) + if(AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP) - if(NOT TARGET LibXml2::LibXml2) - if(AVIF_LOCAL_LIBXML2) - include(LocalLibXml2) - else() - find_package(LibXml2 QUIET) - endif() - endif() + check_avif_option(AVIF_LIBXML2 TARGET LibXml2::LibXml2 PKG_NAME LibXml2) endif() # --------------------------------------------------------------------------------------- @@ -879,10 +877,10 @@ if(WIN32) avif_exclude_safe(genfiles) avif_exclude_safe(minigzip) endif() - if(AVIF_LOCAL_JPEG) + if(AVIF_JPEG STREQUAL "LOCAL") avif_set_folder_safe(JPEG::JPEG "ext/libjpeg-turbo") endif() - if(AVIF_LOCAL_LIBXML2) + if(AVIF_LIBXML2 STREQUAL "LOCAL") avif_set_folder_safe(xml2 "ext/libxml2") endif() endif() diff --git a/README.md b/README.md index 55aa04f622..8efb46bd81 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ cd libavif/ext ./libjpeg.cmd ./zlibpng.cmd cd .. -cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON -DAVIF_LOCAL_LIBYUV=ON -DAVIF_LOCAL_LIBSHARPYUV=ON -DAVIF_LOCAL_JPEG=ON -DAVIF_LOCAL_ZLIBPNG=ON -DAVIF_BUILD_APPS=ON +cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON -DAVIF_LIBYUV=LOCAL -DAVIF_LIBSHARPYUV=LOCAL -DAVIF_JPEG=LOCAL -DAVIF_ZLIBPNG=LOCAL -DAVIF_BUILD_APPS=ON cmake --build build --parallel ``` diff --git a/appveyor.yml b/appveyor.yml index 714e30009e..a161bd83f0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,7 +29,7 @@ install: - mkdir build - cd build - cmake --version - - cmake .. -DAVIF_CODEC_AOM=LOCAL -DAVIF_CODEC_DAV1D=LOCAL -DBUILD_SHARED_LIBS=OFF -DAVIF_LOCAL_JPEG=ON -DAVIF_LOCAL_ZLIBPNG=ON -DAVIF_LIBYUV=LOCAL -DAVIF_BUILD_APPS=ON -DAVIF_ENABLE_WERROR=ON + - cmake .. -DAVIF_CODEC_AOM=LOCAL -DAVIF_CODEC_DAV1D=LOCAL -DBUILD_SHARED_LIBS=OFF -DAVIF_JPEG=JPEG -DAVIF_ZLIBPNG=LOCAL -DAVIF_LIBYUV=LOCAL -DAVIF_BUILD_APPS=ON -DAVIF_ENABLE_WERROR=ON build: project: build/libavif.sln diff --git a/cmake/Modules/LocalGoogletest.cmake b/cmake/Modules/LocalGoogletest.cmake index 4c17c72d5c..d687237f55 100644 --- a/cmake/Modules/LocalGoogletest.cmake +++ b/cmake/Modules/LocalGoogletest.cmake @@ -9,7 +9,7 @@ set(GTEST_MAIN_LIB_FILENAME ${AVIF_SOURCE_DIR}/ext/googletest/build/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} ) if(EXISTS ${GTEST_INCLUDE_DIRS}/gtest/gtest.h AND EXISTS ${GTEST_LIB_FILENAME} AND EXISTS ${GTEST_MAIN_LIB_FILENAME}) - message(STATUS "libavif(AVIF_LOCAL_GTEST): compiled library found in ext/googletest") + message(STATUS "libavif(AVIF_GTEST=LOCAL): compiled library found in ext/googletest") add_library(GTest::gtest STATIC IMPORTED) set_target_properties(GTest::gtest PROPERTIES IMPORTED_LOCATION "${GTEST_LIB_FILENAME}" AVIF_LOCAL ON) @@ -23,9 +23,9 @@ if(EXISTS ${GTEST_INCLUDE_DIRS}/gtest/gtest.h AND EXISTS ${GTEST_LIB_FILENAME} A target_link_libraries(GTest::gtest_main INTERFACE GTest::gtest) set_target_properties(GTest::gtest_main PROPERTIES IMPORTED_LOCATION "${GTEST_MAIN_LIB_FILENAME}" AVIF_LOCAL ON) else() - message(STATUS "libavif(AVIF_LOCAL_GTEST): compiled library not found in ext/googletest; using FetchContent") + message(STATUS "libavif(AVIF_GTEST=LOCAL): compiled library not found in ext/googletest; using FetchContent") if(EXISTS "${AVIF_SOURCE_DIR}/ext/googletest") - message(STATUS "libavif(AVIF_LOCAL_GTEST): ext/googletest found; using as FetchContent SOURCE_DIR") + message(STATUS "libavif(AVIF_GTEST=LOCAL): ext/googletest found; using as FetchContent SOURCE_DIR") set(FETCHCONTENT_SOURCE_DIR_GOOGLETEST "${AVIF_SOURCE_DIR}/ext/googletest") message(CHECK_START "libavif(AVIF_LOCAL_GTEST): configuring googletest") else() diff --git a/cmake/Modules/LocalJpeg.cmake b/cmake/Modules/LocalJpeg.cmake index 818337205b..de4adc4bba 100644 --- a/cmake/Modules/LocalJpeg.cmake +++ b/cmake/Modules/LocalJpeg.cmake @@ -9,10 +9,10 @@ else() set(LIB_FILENAME "${LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}jpeg${CMAKE_STATIC_LIBRARY_SUFFIX}") endif() if(EXISTS "${LIB_FILENAME}") - message(STATUS "libavif(AVIF_LOCAL_JPEG): ${LIB_FILENAME} found, using for local JPEG") + message(STATUS "libavif(AVIF_JPEG=LOCAL): ${LIB_FILENAME} found, using for local JPEG") set(JPEG_INCLUDE_DIR "${AVIF_SOURCE_DIR}/ext/libjpeg-turbo") else() - message(STATUS "libavif(AVIF_LOCAL_JPEG): ${LIB_FILENAME} not found, fetching") + message(STATUS "libavif(AVIF_JPEG=LOCAL): ${LIB_FILENAME} not found, fetching") set(LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/libjpeg/src/libjpeg-build") if(MSVC) set(LIB_FILENAME "${LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}jpeg-static${CMAKE_STATIC_LIBRARY_SUFFIX}") diff --git a/cmake/Modules/LocalLibXml2.cmake b/cmake/Modules/LocalLibXml2.cmake index 97f9eee510..01cdc84ea4 100644 --- a/cmake/Modules/LocalLibXml2.cmake +++ b/cmake/Modules/LocalLibXml2.cmake @@ -2,15 +2,15 @@ set(AVIF_LOCAL_LIBXML_GIT_TAG "v2.11.5") set(LIB_FILENAME "${AVIF_SOURCE_DIR}/ext/libxml2/install.libavif/lib/${AVIF_LIBRARY_PREFIX}xml2${CMAKE_STATIC_LIBRARY_SUFFIX}") if(EXISTS "${LIB_FILENAME}") - message(STATUS "libavif(AVIF_LOCAL_LIBXML2): compiled library found at ${LIB_FILENAME}") + message(STATUS "libavif(AVIF_LIBXML2=LOCAL): compiled library found at ${LIB_FILENAME}") add_library(LibXml2 STATIC IMPORTED GLOBAL) set_target_properties(LibXml2 PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" AVIF_LOCAL ON) target_include_directories(LibXml2 INTERFACE "${AVIF_SOURCE_DIR}/ext/libxml2/install.libavif/include/libxml2") add_library(LibXml2::LibXml2 ALIAS LibXml2) else() - message(STATUS "libavif(AVIF_LOCAL_LIBXML2): compiled library not found at ${LIB_FILENAME}; using FetchContent") + message(STATUS "libavif(AVIF_LIBXML2=LOCAL): compiled library not found at ${LIB_FILENAME}; using FetchContent") if(EXISTS "${AVIF_SOURCE_DIR}/ext/libxml2") - message(STATUS "libavif(AVIF_LOCAL_LIBXML2): ext/libxml2 found; using as FetchContent SOURCE_DIR") + message(STATUS "libavif(AVIF_LIBXML2=LOCAL): ext/libxml2 found; using as FetchContent SOURCE_DIR") set(FETCHCONTENT_SOURCE_DIR_LIBXML2 "${AVIF_SOURCE_DIR}/ext/libxml2") message(CHECK_START "libavif(AVIF_LOCAL_LIBXML2): configuring libxml2") else() diff --git a/ext/README.md b/ext/README.md index c5d2b85627..0d6da9fea5 100644 --- a/ext/README.md +++ b/ext/README.md @@ -3,7 +3,7 @@ This contains references to various external repositories which are known to build and work properly with the current libavif. If you are building for Windows or any kind of fully static (embedded) release, using these scripts in -conjunction with the `BUILD_SHARED_LIBS=0` and `AVIF_LOCAL_*` CMake flags make +conjunction with the `BUILD_SHARED_LIBS=0` and `AVIF_*` CMake flags make for a convenient way to get all of the dependencies necessary. This method is how many of libavif's continuous builders work. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b52d7e58fc..a5c15cc5b2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -87,14 +87,7 @@ macro(add_avif_internal_gtest_with_data TEST_NAME) endmacro() if(AVIF_ENABLE_GTEST) - if(NOT TARGET GTest::gtest) - if(AVIF_LOCAL_GTEST) - include(LocalGoogletest) - else() - find_package(GTest REQUIRED) - endif() - endif() - + check_avif_option(AVIF_GTEST TARGET GTest::gtest PKG_NAME Googletest) add_library(avifincrtest_helpers OBJECT gtest/avifincrtest_helpers.cc) target_link_libraries(avifincrtest_helpers avif_internal GTest::gtest) endif() diff --git a/tests/oss-fuzz/build.sh b/tests/oss-fuzz/build.sh index 517cad8782..6d23900cb3 100755 --- a/tests/oss-fuzz/build.sh +++ b/tests/oss-fuzz/build.sh @@ -82,8 +82,8 @@ cmake .. -G Ninja -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=LOCAL -DAVIF_CODEC_DA -DAVIF_CODEC_AOM_DECODE=ON -DAVIF_CODEC_AOM_ENCODE=ON \ -DAVIF_ENABLE_WERROR=OFF \ -DAVIF_LOCAL_FUZZTEST=ON \ - -DAVIF_LOCAL_GTEST=OFF -DAVIF_LOCAL_JPEG=ON -DAVIF_LOCAL_LIBSHARPYUV=ON \ - -DAVIF_LIBYUV=LOCAL -DAVIF_LOCAL_ZLIBPNG=ON \ + -DAVIF_JPEG=LOCAL -DAVIF_LIBSHARPYUV=LOCAL \ + -DAVIF_LIBYUV=LOCAL -DAVIF_ZLIBPNG=LOCAL \ -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=OFF -DAVIF_ENABLE_WERROR=ON \ ${EXTRA_CMAKE_FLAGS} diff --git a/tests/test_all_configurations.sh b/tests/test_all_configurations.sh index 1f17c6add9..6329153c11 100755 --- a/tests/test_all_configurations.sh +++ b/tests/test_all_configurations.sh @@ -46,10 +46,10 @@ for BUILD_TYPE in Debug Release; do pushd build_${BUILD_TYPE} cmake .. \ -DAVIF_BUILD_APPS=ON -DAVIF_BUILD_EXAMPLES=ON \ - -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON \ + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL \ -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON \ -DAVIF_CODEC_DAV1D=ON -DAVIF_LOCAL_DAV1D=ON \ - -DAVIF_LOCAL_LIBYUV=ON -DAVIF_LOCAL_LIBSHARPYUV=ON \ + -DAVIF_LIBYUV=LOCAL -DAVIF_LIBSHARPYUV=LOCAL \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF cmake --build . --parallel ctest . -j $(nproc) @@ -79,10 +79,10 @@ for BUILD_TYPE in Debug Release; do CC=clang CXX=clang++ CFLAGS=-fsanitize=${SANITIZER} CXXFLAGS=-fsanitize=${SANITIZER} LDFLAGS=-fsanitize=${SANITIZER} \ cmake .. \ -DAVIF_BUILD_APPS=ON -DAVIF_BUILD_EXAMPLES=ON \ - -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON \ + -DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL \ -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON \ -DAVIF_CODEC_DAV1D=ON -DAVIF_LOCAL_DAV1D=ON \ - -DAVIF_LOCAL_LIBYUV=ON -DAVIF_LOCAL_LIBSHARPYUV=ON \ + -DAVIF_LIBYUV=LOCAL -DAVIF_LIBSHARPYUV=LOCAL \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF cmake --build . --parallel ASAN_OPTIONS=allocator_may_return_null=1:detect_odr_violation=0 \