summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindSndio.cmake
blob: 992c0b1ab6b39711a841f6c27da5395269f1c74d (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
#
# FindSndio
# ---------
# Finds the Sndio Library
#
# This will define the following variables:
#
# SNDIO_FOUND - system has sndio
# SNDIO_INCLUDE_DIRS - sndio include directory
# SNDIO_DEFINITIONS - sndio definitions
#
# and the following imported targets::
#
#  Sndio::Sndio    - the sndio library
#

find_path(SNDIO_INCLUDE_DIR sndio.h)
find_library(SNDIO_LIBRARY sndio)


include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sndio
                                  REQUIRED_VARS SNDIO_LIBRARY SNDIO_INCLUDE_DIR)

if(SNDIO_FOUND)
  set(SNDIO_INCLUDE_DIRS ${SNDIO_INCLUDE_DIR})
  set(SNDIO_LIBRARIES ${SNDIO_LIBRARY})
  set(SNDIO_DEFINITIONS -DHAS_SNDIO=1)

  if(NOT TARGET Sndio::Sndio)
    add_library(Sndio::Sndio UNKNOWN IMPORTED)
    set_target_properties(Sndio::Sndio PROPERTIES
                                       IMPORTED_LOCATION "${SNDIO_LIBRARY}"
                                       INTERFACE_INCLUDE_DIRECTORIES "${SNDIO_INCLUDE_DIR}")
    set_target_properties(Sndio::Sndio PROPERTIES
                                       INTERFACE_COMPILE_DEFINITIONS -DHAS_SNDIO=1)
  endif()
endif()


mark_as_advanced(SNDIO_INCLUDE_DIR SNDIO_LIBRARY)