re3-wiiu/cmake/FindSndFile.cmake

68 lines
1.8 KiB
CMake
Raw Permalink Normal View History

2020-10-31 23:14:28 +01:00
# Found on http://hg.kvats.net
#
# - Try to find libsndfile
#
# Once done this will define
#
# SNDFILE_FOUND - system has libsndfile
2020-10-31 23:14:28 +01:00
# SNDFILE_INCLUDE_DIRS - the libsndfile include directory
# SNDFILE_LIBRARIES - Link these to use libsndfile
# SNDFILE_CFLAGS - Compile options to use libsndfile
# SndFile::SndFile - Imported library of libsndfile
2020-10-31 23:14:28 +01:00
#
# Copyright (C) 2006 Wengo
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_search_module(PKG_SNDFILE "sndfile")
endif()
2020-10-31 23:14:28 +01:00
find_path(SNDFILE_INCLUDE_DIR
2020-10-31 23:14:28 +01:00
NAMES
sndfile.h
HINTS
${PKG_SNDFILE_INCLUDE_DIRS}
2020-10-31 23:14:28 +01:00
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
find_library(SNDFILE_LIBRARY
2020-10-31 23:14:28 +01:00
NAMES
sndfile
HINTS
${PKG_SNDFILE_LIBRARIES}
2020-10-31 23:14:28 +01:00
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
set(SNDFILE_CFLAGS "${PKG_SNDFILE_CFLAGS_OTHER}" CACHE STRING "CFLAGS of libsndfile")
2020-10-31 23:14:28 +01:00
set(SNDFILE_INCLUDE_DIRS "${SNDFILE_INCLUDE_DIR}")
set(SNDFILE_LIBRARIES "${SNDFILE_LIBRARY}")
2020-10-31 23:14:28 +01:00
2021-01-03 16:30:45 +01:00
if(SNDFILE_INCLUDE_DIRS AND SNDFILE_LIBRARIES)
set(SNDFILE_FOUND TRUE)
endif()
2020-10-31 23:14:28 +01:00
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SndFile DEFAULT_MSG SNDFILE_INCLUDE_DIRS SNDFILE_LIBRARIES)
2020-10-31 23:14:28 +01:00
if(NOT TARGET SndFile::SndFile)
add_library(__SndFile INTERFACE)
target_compile_options(__SndFile INTERFACE ${SNDFILE_CFLAGS})
target_include_directories(__SndFile INTERFACE ${SNDFILE_INCLUDE_DIRS})
target_link_libraries(__SndFile INTERFACE ${SNDFILE_LIBRARIES})
add_library(SndFile::SndFile ALIAS __SndFile)
endif()