aboutsummaryrefslogtreecommitdiff
path: root/cmake/modules/FindAML.cmake
blob: 89d1fd985dbbe7f4d7b6e0a6f69e9c8d0352e732 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#.rst:
# FindAML
# -------
# Finds the AML codec
#
# This will define the following variables::
#
# AML_FOUND - system has AML
# AML_INCLUDE_DIRS - the AML include directory
# AML_DEFINITIONS - the AML definitions
#
# and the following imported targets::
#
#   AML::AML   - The AML codec

find_path(AML_INCLUDE_DIR codec_error.h
                          PATH_SUFFIXES amcodec)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(AML
                                  REQUIRED_VARS AML_INCLUDE_DIR)

include(CheckCSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${AML_INCLUDE_DIR})
check_c_source_compiles("#include <amcodec/codec.h>

                         int main()
                         {
                           int i = VIDEO_DEC_FORMAT_VP9;
                           return 0;
                         }
                         " AML_HAS_VP9)

if(AML_FOUND)
  set(AML_INCLUDE_DIRS ${AML_INCLUDE_DIR})
  set(AML_DEFINITIONS -DHAS_LIBAMCODEC=1)
  if(AML_HAS_VP9)
    list(APPEND AML_DEFINITIONS -DHAS_LIBAMCODEC_VP9=1)
  endif()

  if(NOT TARGET AML::AML)
    add_library(AML::AML UNKNOWN IMPORTED)
    set_target_properties(AML::AML PROPERTIES
                                   INTERFACE_INCLUDE_DIRECTORIES "${AML_INCLUDE_DIR}"
                                   INTERFACE_COMPILE_DEFINITIONS HAS_LIBAMCODEC=1)
  endif()
endif()

mark_as_advanced(AMLCODEC_INCLUDE_DIR)