diff options
Diffstat (limited to '')
-rw-r--r-- | cmake/FindSndFile.cmake | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/cmake/FindSndFile.cmake b/cmake/FindSndFile.cmake index 8ae47b70..5381af48 100644 --- a/cmake/FindSndFile.cmake +++ b/cmake/FindSndFile.cmake @@ -4,9 +4,11 @@ # # Once done this will define # -# SNDFILE_FOUND - system has libsndfile +# SNDFILE_FOUND - system has libsndfile # SNDFILE_INCLUDE_DIRS - the libsndfile include directory -# SNDFILE_LIBRARIES - Link these to use libsndfile +# SNDFILE_LIBRARIES - Link these to use libsndfile +# SNDFILE_CFLAGS - Compile options to use libsndfile +# SndFile::SndFile - Imported library of libsndfile # # Copyright (C) 2006 Wengo # @@ -15,53 +17,51 @@ # For details see the accompanying COPYING-CMAKE-SCRIPTS file. # -if (SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIRS) - # in cache already - set(SNDFILE_FOUND TRUE) -else (SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIRS) +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PKG_SNDFILE "sndfile") +endif() - find_path(SNDFILE_INCLUDE_DIR +find_path(SNDFILE_INCLUDE_DIR NAMES - sndfile.h + sndfile.h + HINTS + ${PKG_SNDFILE_INCLUDE_DIRS} PATHS - /usr/include - /usr/local/include - /opt/local/include - /sw/include - ) - - find_library(SNDFILE_LIBRARY + /usr/include + /usr/local/include + /opt/local/include + /sw/include + ) + +find_library(SNDFILE_LIBRARY NAMES - sndfile + sndfile + HINTS + ${PKG_SNDFILE_LIBRARIES} PATHS - /usr/lib - /usr/local/lib - /opt/local/lib - /sw/lib - ) + /usr/lib + /usr/local/lib + /opt/local/lib + /sw/lib +) - set(SNDFILE_INCLUDE_DIRS - ${SNDFILE_INCLUDE_DIR} - ) - set(SNDFILE_LIBRARIES - ${SNDFILE_LIBRARY} - ) +set(SNDFILE_CFLAGS "${PKG_SNDFILE_CFLAGS_OTHER}" CACHE STRING "CFLAGS of libsndfile") - if (SNDFILE_INCLUDE_DIRS AND SNDFILE_LIBRARIES) - set(SNDFILE_FOUND TRUE) - endif (SNDFILE_INCLUDE_DIRS AND SNDFILE_LIBRARIES) +set(SNDFILE_INCLUDE_DIRS "${SNDFILE_INCLUDE_DIR}") +set(SNDFILE_LIBRARIES "${SNDFILE_LIBRARY}") - if (SNDFILE_FOUND) - if (NOT SndFile_FIND_QUIETLY) - message(STATUS "Found libsndfile: ${SNDFILE_LIBRARIES}") - endif (NOT SndFile_FIND_QUIETLY) - else (SNDFILE_FOUND) - if (SndFile_FIND_REQUIRED) - message(FATAL_ERROR "Could not find libsndfile") - endif (SndFile_FIND_REQUIRED) - endif (SNDFILE_FOUND) +if(SNDFILE_INCLUDE_DIRS AND SNDFILE_LIBRARIES) + set(SNDFILE_FOUND TRUE) +endif() - # show the SNDFILE_INCLUDE_DIRS and SNDFILE_LIBRARIES variables only in the advanced view - mark_as_advanced(SNDFILE_INCLUDE_DIRS SNDFILE_LIBRARIES) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(SndFile DEFAULT_MSG SNDFILE_INCLUDE_DIRS SNDFILE_LIBRARIES) -endif (SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIRS) +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() |