1# This file is part of Mixxx, Digital DJ'ing software.
2# Copyright (C) 2001-2020 Mixxx Development Team
3# Distributed under the GNU General Public Licence (GPL) version 2 or any later
4# later version. See the LICENSE file for details.
5
6#[=======================================================================[.rst:
7FindMP4
8-------
9
10Finds the MP4 library.
11
12Imported Targets
13^^^^^^^^^^^^^^^^
14
15This module provides the following imported targets, if found:
16
17``MP4::MP4``
18  The MP4 library
19
20Result Variables
21^^^^^^^^^^^^^^^^
22
23This will define the following variables:
24
25``MP4_FOUND``
26  True if the system has the MP4 library.
27``MP4_INCLUDE_DIRS``
28  Include directories needed to use MP4.
29``MP4_LIBRARIES``
30  Libraries needed to link to MP4.
31``MP4_DEFINITIONS``
32  Compile definitions needed to use MP4.
33
34Cache Variables
35^^^^^^^^^^^^^^^
36
37The following cache variables may also be set:
38
39``MP4_INCLUDE_DIR``
40  The directory containing ``mp4/mp4.h``.
41``MP4_LIBRARY``
42  The path to the MP4 library.
43
44#]=======================================================================]
45
46find_package(PkgConfig QUIET)
47if(PkgConfig_FOUND)
48  pkg_check_modules(PC_MP4 QUIET mp4)
49endif()
50
51find_path(MP4_INCLUDE_DIR
52  NAMES mp4/mp4.h
53  PATHS ${PC_MP4_INCLUDE_DIRS}
54  DOC "MP4 include directory")
55mark_as_advanced(MP4_INCLUDE_DIR)
56
57find_library(MP4_LIBRARY
58  NAMES mp4
59  PATHS ${PC_MP4_LIBRARY_DIRS}
60  DOC "MP4 library"
61)
62mark_as_advanced(MP4_LIBRARY)
63
64include(FindPackageHandleStandardArgs)
65find_package_handle_standard_args(
66  MP4
67  DEFAULT_MSG
68  MP4_LIBRARY
69  MP4_INCLUDE_DIR
70)
71
72if(MP4_FOUND)
73  set(MP4_LIBRARIES "${MP4_LIBRARY}")
74  set(MP4_INCLUDE_DIRS "${MP4_INCLUDE_DIR}")
75  set(MP4_DEFINITIONS ${PC_MP4_CFLAGS_OTHER})
76
77  if(NOT TARGET MP4::MP4)
78    add_library(MP4::MP4 UNKNOWN IMPORTED)
79    set_target_properties(MP4::MP4
80      PROPERTIES
81        IMPORTED_LOCATION "${MP4_LIBRARY}"
82        INTERFACE_COMPILE_OPTIONS "${PC_MP4_CFLAGS_OTHER}"
83        INTERFACE_INCLUDE_DIRECTORIES "${MP4_INCLUDE_DIR}"
84    )
85  endif()
86endif()
87