1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-18 11:47:45 +00:00
re3/cmake/FindSndFile.cmake

68 lines
1.8 KiB
CMake
Raw Normal View History

2020-10-31 22:14:28 +00:00
# Found on http://hg.kvats.net
#
# - Try to find libsndfile
#
# Once done this will define
#
2021-01-13 11:45:10 +00:00
# SNDFILE_FOUND - system has libsndfile
2020-10-31 22:14:28 +00:00
# SNDFILE_INCLUDE_DIRS - the libsndfile include directory
2021-01-13 11:45:10 +00:00
# SNDFILE_LIBRARIES - Link these to use libsndfile
# SNDFILE_CFLAGS - Compile options to use libsndfile
# SndFile::SndFile - Imported library of libsndfile
2020-10-31 22:14:28 +00: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.
#
2021-01-13 11:45:10 +00:00
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_search_module(PKG_SNDFILE "sndfile")
endif()
2020-10-31 22:14:28 +00:00
2021-01-13 11:45:10 +00:00
find_path(SNDFILE_INCLUDE_DIR
2020-10-31 22:14:28 +00:00
NAMES
2021-01-13 11:45:10 +00:00
sndfile.h
HINTS
${PKG_SNDFILE_INCLUDE_DIRS}
2020-10-31 22:14:28 +00:00
PATHS
2021-01-13 11:45:10 +00:00
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
find_library(SNDFILE_LIBRARY
2020-10-31 22:14:28 +00:00
NAMES
2021-01-13 11:45:10 +00:00
sndfile
HINTS
${PKG_SNDFILE_LIBRARIES}
2020-10-31 22:14:28 +00:00
PATHS
2021-01-13 11:45:10 +00:00
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
2020-10-31 22:14:28 +00:00
2021-01-13 11:45:10 +00:00
set(SNDFILE_CFLAGS "${PKG_SNDFILE_CFLAGS_OTHER}" CACHE STRING "CFLAGS of libsndfile")
2020-10-31 22:14:28 +00:00
2021-01-13 11:45:10 +00:00
set(SNDFILE_INCLUDE_DIRS "${SNDFILE_INCLUDE_DIR}")
set(SNDFILE_LIBRARIES "${SNDFILE_LIBRARY}")
2020-10-31 22:14:28 +00:00
2021-01-13 11:45:10 +00:00
if(SNDFILE_INCLUDE_DIRS AND SNDFILE_LIBRARIES)
set(SNDFILE_FOUND TRUE)
endif()
2020-10-31 22:14:28 +00:00
2021-01-13 11:45:10 +00:00
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SndFile DEFAULT_MSG SNDFILE_INCLUDE_DIRS SNDFILE_LIBRARIES)
2020-10-31 22:14:28 +00:00
2021-01-13 11:45:10 +00: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()