FindSndFile.cmake 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # FindSndFile.cmake - Try to find libsndfile
  2. # Copyright (c) 2018 Lukas W <lukaswhl/at/gmail.com>
  3. # This file is MIT licensed.
  4. # See http://opensource.org/licenses/MIT
  5. # Try pkgconfig for hints
  6. find_package(PkgConfig QUIET)
  7. if(PKG_CONFIG_FOUND)
  8. pkg_check_modules(SNDFILE_PKG sndfile)
  9. endif(PKG_CONFIG_FOUND)
  10. set(SndFile_DEFINITIONS ${SNDFILE_PKG_CFLAGS_OTHER})
  11. if(WIN32)
  12. # Try Vcpkg
  13. find_package(LibSndFile ${SndFile_FIND_VERSION} CONFIG QUIET)
  14. if(LibSndFile_FOUND)
  15. get_target_property(LibSndFile_Location sndfile-shared LOCATION)
  16. get_target_property(LibSndFile_Include_Path sndfile-shared INTERFACE_INCLUDE_DIRECTORIES)
  17. get_filename_component(LibSndFile_Path LibSndFile_Location PATH)
  18. endif()
  19. endif()
  20. find_path(SNDFILE_INCLUDE_DIR
  21. NAMES sndfile.h
  22. PATHS ${SNDFILE_PKG_INCLUDE_DIRS} ${LibSndFile_Include_Path}
  23. )
  24. find_library(SNDFILE_LIBRARY
  25. NAMES sndfile libsndfile libsndfile-1
  26. PATHS ${SNDFILE_PKG_LIBRARY_DIRS} ${LibSndFile_Path}
  27. )
  28. find_package(PackageHandleStandardArgs)
  29. find_package_handle_standard_args(SndFile DEFAULT_MSG SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
  30. set(SNDFILE_LIBRARIES ${SNDFILE_LIBRARY})
  31. set(SNDFILE_INCLUDE_DIRS ${SNDFILE_INCLUDE_DIR})
  32. mark_as_advanced(SNDFILE_LIBRARY SNDFILE_LIBRARIES SNDFILE_INCLUDE_DIR SNDFILE_INCLUDE_DIRS)