summaryrefslogtreecommitdiffstats
path: root/cmake/modules/Findlilv.cmake
blob: 0385b81526ead5f738c8882ce0b8733736f692d1 (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
87
88
89
90
91
92
93
94
95
96
97
# This file is part of Mixxx, Digital DJ'ing software.
# Copyright (C) 2001-2023 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:
Findlilv
--------

Finds the lilv library and lv2-dev package containing 'units' headers.

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

This module provides the following imported targets, if found:

``lilv::lilv``
  The lilv library

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

This will define the following variables:

``lilv_FOUND``
  True if the system has the lilv library.
``lilv_INCLUDE_DIRS``
  Include directories needed to use lilv.
``lilv_LIBRARIES``
  Libraries needed to link to lilv.
``lilv_DEFINITIONS``
  Compile definitions needed to use lilv.

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

The following cache variables may also be set:

``lilv_INCLUDE_DIR``
  The directory containing ``lilv-0/lilv/lilv.h``.
``lilv_LIBRARY``
  The path to the lilv library.

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

include(IsStaticLibrary)

find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
  pkg_check_modules(PC_lilv QUIET lilv-0 lv2)
endif()

find_path(lilv_INCLUDE_DIR
  NAMES lilv/lilv.h
  PATH_SUFFIXES lilv-0
  PATHS ${PC_lilv_INCLUDE_DIRS}
  DOC "lilv include directory"
)
mark_as_advanced(lilv_INCLUDE_DIR)

find_library(lilv_LIBRARY
  NAMES lilv-0 lilv
  PATHS ${PC_lilv_LIBRARY_DIRS}
  DOC "lilv library"
)
mark_as_advanced(lilv_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
  lilv
  DEFAULT_MSG
  lilv_LIBRARY
  lilv_INCLUDE_DIR
)

if(lilv_FOUND)
  set(lilv_LIBRARIES "${lilv_LIBRARY}")
  set(lilv_INCLUDE_DIRS "${lilv_INCLUDE_DIR}")
  set(lilv_DEFINITIONS ${PC_lilv_CFLAGS_OTHER})

  if(NOT TARGET lilv::lilv)
    add_library(lilv::lilv UNKNOWN IMPORTED)
    set_target_properties(lilv::lilv
      PROPERTIES
        IMPORTED_LOCATION "${lilv_LIBRARY}"
        INTERFACE_COMPILE_OPTIONS "${PC_lilv_CFLAGS_OTHER}"
        INTERFACE_INCLUDE_DIRECTORIES "${lilv_INCLUDE_DIR}"
    )
    is_static_library(lilv_IS_STATIC lilv::lilv)
    if(lilv_IS_STATIC)
      find_package(sord CONFIG REQUIRED)
      set_property(TARGET lilv::lilv APPEND PROPERTY INTERFACE_LINK_LIBRARIES
          sord::sord
      )
    endif()
  endif()
endif()