xref: /third_party/libsnd/cmake/FindSndio.cmake (revision b815c7f3)
1b815c7f3Sopenharmony_ci# - Find SoundIO (sndio) includes and libraries
2b815c7f3Sopenharmony_ci#
3b815c7f3Sopenharmony_ci#   SNDIO_FOUND        - True if SNDIO_INCLUDE_DIR & SNDIO_LIBRARY are
4b815c7f3Sopenharmony_ci#                        found
5b815c7f3Sopenharmony_ci#   SNDIO_LIBRARIES    - Set when SNDIO_LIBRARY is found
6b815c7f3Sopenharmony_ci#   SNDIO_INCLUDE_DIRS - Set when SNDIO_INCLUDE_DIR is found
7b815c7f3Sopenharmony_ci#
8b815c7f3Sopenharmony_ci#   SNDIO_INCLUDE_DIR - where to find sndio.h, etc.
9b815c7f3Sopenharmony_ci#   SNDIO_LIBRARY     - the sndio library
10b815c7f3Sopenharmony_ci#
11b815c7f3Sopenharmony_ci
12b815c7f3Sopenharmony_ciif (SNDIO_INCLUDE_DIR)
13b815c7f3Sopenharmony_ci	# Already in cache, be silent
14b815c7f3Sopenharmony_ci	set (SNDIO_FIND_QUIETLY TRUE)
15b815c7f3Sopenharmony_ciendif ()
16b815c7f3Sopenharmony_ci
17b815c7f3Sopenharmony_cifind_package (PkgConfig QUIET)
18b815c7f3Sopenharmony_cipkg_check_modules (PC_SNDIO QUIET sndio)
19b815c7f3Sopenharmony_ci
20b815c7f3Sopenharmony_ciset (SNDIO_VERSION ${PC_SNDIO_VERSION})
21b815c7f3Sopenharmony_ci
22b815c7f3Sopenharmony_cifind_path (SNDIO_INCLUDE_DIR
23b815c7f3Sopenharmony_ci	NAMES
24b815c7f3Sopenharmony_ci		sndio.h
25b815c7f3Sopenharmony_ci	HINTS
26b815c7f3Sopenharmony_ci		${PC_SNDIO_INCLUDEDIR}
27b815c7f3Sopenharmony_ci		${PC_SNDIO_INCLUDE_DIRS}
28b815c7f3Sopenharmony_ci		${SNDIO_ROOT}
29b815c7f3Sopenharmony_ci	)
30b815c7f3Sopenharmony_ci
31b815c7f3Sopenharmony_cifind_library (SNDIO_LIBRARY
32b815c7f3Sopenharmony_ci	NAMES
33b815c7f3Sopenharmony_ci		sndio
34b815c7f3Sopenharmony_ci	HINTS
35b815c7f3Sopenharmony_ci		${PC_SNDIO_LIBDIR}
36b815c7f3Sopenharmony_ci		${PC_SNDIO_LIBRARY_DIRS}
37b815c7f3Sopenharmony_ci		${SNDIO_ROOT}
38b815c7f3Sopenharmony_ci	)
39b815c7f3Sopenharmony_ci
40b815c7f3Sopenharmony_ciinclude (FindPackageHandleStandardArgs)
41b815c7f3Sopenharmony_cifind_package_handle_standard_args (Sndio
42b815c7f3Sopenharmony_ci	REQUIRED_VARS
43b815c7f3Sopenharmony_ci		SNDIO_LIBRARY
44b815c7f3Sopenharmony_ci		SNDIO_INCLUDE_DIR
45b815c7f3Sopenharmony_ci	VERSION_VAR
46b815c7f3Sopenharmony_ci		SNDIO_VERSION
47b815c7f3Sopenharmony_ci	)
48b815c7f3Sopenharmony_ci
49b815c7f3Sopenharmony_ciif (SNDIO_FOUND)
50b815c7f3Sopenharmony_ci	set (SNDIO_LIBRARIES ${SNDIO_LIBRARY})
51b815c7f3Sopenharmony_ci	set (SNDIO_INCLUDE_DIRS ${SNDIO_INCLUDE_DIR})
52b815c7f3Sopenharmony_ci	if (NOT TARGET Sndio::Sndio)
53b815c7f3Sopenharmony_ci		add_library (Sndio::Sndio UNKNOWN IMPORTED)
54b815c7f3Sopenharmony_ci		set_target_properties (Sndio::Sndio PROPERTIES
55b815c7f3Sopenharmony_ci			INTERFACE_INCLUDE_DIRECTORIES "${SNDIO_INCLUDE_DIRS}"
56b815c7f3Sopenharmony_ci			IMPORTED_LOCATION "${SNDIO_LIBRARIES}"
57b815c7f3Sopenharmony_ci		)
58b815c7f3Sopenharmony_ci	endif()
59b815c7f3Sopenharmony_ciendif()
60b815c7f3Sopenharmony_ci
61b815c7f3Sopenharmony_cimark_as_advanced (SNDIO_INCLUDE_DIR SNDIO_LIBRARY)
62