| 1 |
# Copyright (C) 2021 Sony Interactive Entertainment Inc. |
| 2 |
# |
| 3 |
# Redistribution and use in source and binary forms, with or without |
| 4 |
# modification, are permitted provided that the following conditions |
| 5 |
# are met: |
| 6 |
# 1. Redistributions of source code must retain the above copyright |
| 7 |
# notice, this list of conditions and the following disclaimer. |
| 8 |
# 2. Redistributions in binary form must reproduce the above copyright |
| 9 |
# notice, this list of conditions and the following disclaimer in the |
| 10 |
# documentation and/or other materials provided with the distribution. |
| 11 |
# |
| 12 |
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 13 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 14 |
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 15 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 16 |
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 17 |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 18 |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 19 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 20 |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 21 |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 22 |
# THE POSSIBILITY OF SUCH DAMAGE. |
| 23 |
|
| 24 |
#[=======================================================================[.rst: |
| 25 |
FindJPEGXL |
| 26 |
--------- |
| 27 |
|
| 28 |
Find JPEGXL headers and libraries. |
| 29 |
|
| 30 |
Imported Targets |
| 31 |
^^^^^^^^^^^^^^^^ |
| 32 |
|
| 33 |
``JPEGXL::jxl`` |
| 34 |
The JPEGXL library, if found. |
| 35 |
|
| 36 |
Result Variables |
| 37 |
^^^^^^^^^^^^^^^^ |
| 38 |
|
| 39 |
This will define the following variables in your project: |
| 40 |
|
| 41 |
``JPEGXL_FOUND`` |
| 42 |
true if (the requested version of) JPEGXL is available. |
| 43 |
``JPEGXL_VERSION`` |
| 44 |
the version of JPEGXL. |
| 45 |
``JPEGXL_LIBRARIES`` |
| 46 |
the libraries to link against to use JPEGXL. |
| 47 |
``JPEGXL_INCLUDE_DIRS`` |
| 48 |
where to find the JPEGXL headers. |
| 49 |
``JPEGXL_COMPILE_OPTIONS`` |
| 50 |
this should be passed to target_compile_options(), if the |
| 51 |
target is not used for linking |
| 52 |
|
| 53 |
#]=======================================================================] |
| 54 |
|
| 55 |
find_package(PkgConfig QUIET) |
| 56 |
if (PkgConfig_FOUND) |
| 57 |
pkg_check_modules(PC_JPEGXL QUIET libjxl) |
| 58 |
set(JPEGXL_COMPILE_OPTIONS "${PC_JPEGXL_CFLAGS_OTHER}") |
| 59 |
set(JPEGXL_VERSION ${PC_JPEGXL_VERSION}) |
| 60 |
|
| 61 |
pkg_check_modules(PC_JPEGXL_THREADS QUIET libjxl_threads) |
| 62 |
set(JPEGXL_THREADS_COMPILE_OPTIONS ${PC_JPEGXL_THREADS_CFLAGS_OTHER}) |
| 63 |
endif () |
| 64 |
|
| 65 |
find_path(JPEGXL_INCLUDE_DIR |
| 66 |
NAMES jxl/decode.h |
| 67 |
HINTS ${PC_JPEGXL_INCLUDEDIR} ${PC_JPEGXL_INCLUDE_DIRS} ${JPEGXL_INCLUDE_DIR} |
| 68 |
) |
| 69 |
|
| 70 |
find_library(JPEGXL_LIBRARY |
| 71 |
NAMES ${JPEGXL_NAMES} jxl |
| 72 |
HINTS ${PC_JPEGXL_LIBDIR} ${PC_JPEGXL_LIBRARY_DIRS} |
| 73 |
) |
| 74 |
|
| 75 |
find_library(JPEGXL_THREADS_LIBRARY |
| 76 |
NAMES ${JPEGXL_NAMES} jxl_threads |
| 77 |
HINTS ${PC_JPEGXL_LIBDIR} ${PC_JPEGXL_LIBRARY_DIRS} ${PC_JPEGXL_THREADS_LIBDIR} ${PC_JPEGXL_THREADS_LIBRARY_DIRS} |
| 78 |
) |
| 79 |
|
| 80 |
include(FindPackageHandleStandardArgs) |
| 81 |
find_package_handle_standard_args(JPEGXL |
| 82 |
FOUND_VAR JPEGXL_FOUND |
| 83 |
REQUIRED_VARS JPEGXL_LIBRARY JPEGXL_INCLUDE_DIR |
| 84 |
VERSION_VAR JPEGXL_VERSION |
| 85 |
) |
| 86 |
|
| 87 |
if (JPEGXL_LIBRARY AND NOT TARGET JPEGXL::jxl) |
| 88 |
add_library(JPEGXL::jxl UNKNOWN IMPORTED GLOBAL) |
| 89 |
set_target_properties(JPEGXL::jxl PROPERTIES |
| 90 |
IMPORTED_LOCATION "${JPEGXL_LIBRARY}" |
| 91 |
INTERFACE_COMPILE_OPTIONS "${JPEGXL_COMPILE_OPTIONS}" |
| 92 |
INTERFACE_INCLUDE_DIRECTORIES "${JPEGXL_INCLUDE_DIR}" |
| 93 |
) |
| 94 |
endif () |
| 95 |
|
| 96 |
if (JPEGXL_THREADS_LIBRARY AND NOT TARGET JPEGXL::jxl_threads) |
| 97 |
add_library(JPEGXL::jxl_threads UNKNOWN IMPORTED GLOBAL) |
| 98 |
set_target_properties(JPEGXL::jxl_threads PROPERTIES |
| 99 |
IMPORTED_LOCATION "${JPEGXL_THREADS_LIBRARY}" |
| 100 |
INTERFACE_COMPILE_OPTIONS "${JPEGXL_THREADS_COMPILE_OPTIONS}" |
| 101 |
INTERFACE_INCLUDE_DIRECTORIES "${JPEGXL_INCLUDE_DIR}" |
| 102 |
) |
| 103 |
endif () |
| 104 |
|
| 105 |
mark_as_advanced(JPEGXL_INCLUDE_DIR JPEGXL_LIBRARY JPEGXL_THREADS_LIBRARY) |
| 106 |
|
| 107 |
if (JPEGXL_FOUND) |
| 108 |
set(JPEGXL_LIBRARIES ${JPEGXL_LIBRARY}) |
| 109 |
set(JPEGXL_INCLUDE_DIRS ${JPEGXL_INCLUDE_DIR}) |
| 110 |
endif () |
| 111 |
|
| 112 |
if (JPEGXL_THREADS_LIBRARY) |
| 113 |
list(APPEND JPEGXL_LIBRARIES ${JPEGXL_THREADS_LIBRARY}) |
| 114 |
endif () |