From 7a91ba9311431e93e9edf2e05cb0afebcea95cea Mon Sep 17 00:00:00 2001 From: Levin Li Date: Sat, 9 Oct 2021 17:16:07 +0800 Subject: [PATCH] Update build script --- CMakeLists.txt | 4 +++ cmake/FindLibavif.cmake | 59 +++++++++++++++++++++++++++++++++++++ src/celimage/CMakeLists.txt | 1 + 3 files changed, 64 insertions(+) create mode 100644 cmake/FindLibavif.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2efcc8cfe..e7108d014 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,6 +212,10 @@ find_package(JPEG REQUIRED) # -DJPEG_LIBRARY=... include_directories(${JPEG_INCLUDE_DIRS}) link_libraries(${JPEG_LIBRARIES}) +find_package(Libavif REQUIRED) +link_libraries(libavif::libavif) +include_directories(${LIBAVIF_INCLUDE_DIR}) + if(ENABLE_CELX) add_definitions(-DCELX) diff --git a/cmake/FindLibavif.cmake b/cmake/FindLibavif.cmake new file mode 100644 index 000000000..d14bb4dfe --- /dev/null +++ b/cmake/FindLibavif.cmake @@ -0,0 +1,59 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindLibavif +# -------- +# +# Find the avif headers and libraries. +# +# This module reports information about the avif +# installation in several variables. General variables:: +# +# LIBAVIF_FOUND - true if the avif headers and libraries were found +# LIBAVIF_INCLUDE_DIRS - the directory containing the avif headers +# LIBAVIF_LIBRARIES - avif libraries to be linked +# +# The following cache variables may also be set:: +# +# LIBAVIF_INCLUDE_DIR - the directory containing the avif headers +# LIBAVIF_LIBRARY - the avif library (if any) + +# Find include directory + +# TODO: use pkgconfig + +find_path(LIBAVIF_INCLUDE_DIR + NAMES avif/avif.h + HINTS LIBAVIF_DIR + DOC "avif headers") +mark_as_advanced(LIBAVIF_INCLUDE_DIR) + +find_library(LIBAVIF_LIBRARY + NAMES avif + HINTS LIBAVIF_DIR + DOC "avif libraries") +mark_as_advanced(LIBAVIF_LIBRARY) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libavif + FOUND_VAR LIBAVIF_FOUND + REQUIRED_VARS LIBAVIF_INCLUDE_DIR LIBAVIF_LIBRARY + FAIL_MESSAGE "Failed to find avif") + +if(LIBAVIF_FOUND) + set(LIBAVIF_INCLUDE_DIRS "${LIBAVIF_INCLUDE_DIR}") + if(LIBAVIF_LIBRARY) + set(LIBAVIF_LIBRARIES "${LIBAVIF_LIBRARY}") + else() + unset(LIBAVIF_LIBRARIES) + endif() + + if(NOT TARGET libavif::libavif) + add_library(libavif::libavif UNKNOWN IMPORTED) + set_target_properties(libavif::libavif PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${LIBAVIF_INCLUDE_DIRS}") + set_target_properties(libavif::libavif PROPERTIES + IMPORTED_LOCATION "${LIBAVIF_LIBRARY}") + endif() +endif() diff --git a/src/celimage/CMakeLists.txt b/src/celimage/CMakeLists.txt index 7ecb46907..f9de5f949 100644 --- a/src/celimage/CMakeLists.txt +++ b/src/celimage/CMakeLists.txt @@ -1,4 +1,5 @@ set(CELIMAGE_SOURCES + avif.cpp bmp.cpp dds.cpp dds_decompress.cpp