summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindRubberband.cmake
blob: 4f4046ea6287c23a69ee204f506f1fd04bb5dfcc (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# This file is part of Mixxx, Digital DJ'ing software.
# Copyright (C) 2001-2020 Mixxx Development Team
# Distributed under the GNU General Public Licence (GPL) version 2 or any later
# later version. See the LICENSE file for details.

#[=======================================================================[.rst:
FindRubberband
--------------

Finds the Rubberband library.

Imported Targets
^^^^^^^^^^^^^^^^

This module provides the following imported targets, if found:

``Rubberband::Rubberband``
  The Rubberband library

Result Variables
^^^^^^^^^^^^^^^^

This will define the following variables:

``Rubberband_FOUND``
  True if the system has the Rubberband library.
``Rubberband_INCLUDE_DIRS``
  Include directories needed to use Rubberband.
``Rubberband_LIBRARIES``
  Libraries needed to link to Rubberband.
``Rubberband_DEFINITIONS``
  Compile definitions needed to use Rubberband.

Cache Variables
^^^^^^^^^^^^^^^

The following cache variables may also be set:

``Rubberband_INCLUDE_DIR``
  The directory containing ``rubberband/RubberBandStretcher.h``.
``Rubberband_LIBRARY``
  The path to the Rubberband library.

#]=======================================================================]

find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
  pkg_check_modules(PC_Rubberband QUIET rubberband)
endif()

find_path(Rubberband_INCLUDE_DIR
  NAMES rubberband/RubberBandStretcher.h
  PATHS ${PC_Rubberband_INCLUDE_DIRS}
  DOC "Rubberband include directory")
mark_as_advanced(Rubberband_INCLUDE_DIR)

find_library(Rubberband_LIBRARY
  NAMES rubberband
  PATHS ${PC_Rubberband_LIBRARY_DIRS}
  DOC "Rubberband library"
)
mark_as_advanced(Rubberband_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
  Rubberband
  DEFAULT_MSG
  Rubberband_LIBRARY
  Rubberband_INCLUDE_DIR
)

if(Rubberband_FOUND)
  set(Rubberband_LIBRARIES "${Rubberband_LIBRARY}")
  set(Rubberband_INCLUDE_DIRS "${Rubberband_INCLUDE_DIR}")
  set(Rubberband_DEFINITIONS ${PC_Rubberband_CFLAGS_OTHER})

  if(NOT TARGET Rubberband::Rubberband)
    add_library(Rubberband::Rubberband UNKNOWN IMPORTED)
    set_target_properties(Rubberband::Rubberband
      PROPERTIES
        IMPORTED_LOCATION "${Rubberband_LIBRARY}"
        INTERFACE_COMPILE_OPTIONS "${PC_Rubberband_CFLAGS_OTHER}"
        INTERFACE_INCLUDE_DIRECTORIES "${Rubberband_INCLUDE_DIR}"
    )
  endif()
endif()