[go: up one dir, main page]

File: FindSndFile.cmake

package info (click to toggle)
colobot 0.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 415,516 kB
  • sloc: cpp: 129,242; ansic: 8,872; python: 2,158; sh: 672; awk: 91; xml: 35; makefile: 31
file content (31 lines) | stat: -rw-r--r-- 1,218 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Note: LibSndFile exports targets itself with SndFileConfig.cmake,
#    However, the file is not for some reason provided in packages in some Linux distros, e.g. Ubuntu 18.04
#    Hence this Find*.cmake file.

FIND_PATH(SndFile_INCLUDE_DIR sndfile.h)
FIND_LIBRARY(SndFile_LIBRARY NAMES sndfile libsndfile sndfile-1)

find_package_handle_standard_args(
    SndFile
    DEFAULT_MSG
    SndFile_LIBRARY
    SndFile_INCLUDE_DIR
)

# Export targets
if(SndFile_FOUND AND NOT TARGET SndFile::sndfile)
    add_library(SndFile::sndfile UNKNOWN IMPORTED)
    set_target_properties(SndFile::sndfile PROPERTIES
                          IMPORTED_LOCATION "${SndFile_LIBRARY}"
                          INTERFACE_INCLUDE_DIRECTORIES "${SndFile_INCLUDE_DIR}")
    # If we want to statically link it, we also need its dependencies
    if(SNDFILE_STATIC)
        find_package(Ogg REQUIRED)
        find_package(Opus REQUIRED)
        find_package(FLAC REQUIRED)
        find_package(Vorbis REQUIRED)
        find_package(VorbisEnc REQUIRED)
        set_property(TARGET SndFile::sndfile APPEND PROPERTY
                     INTERFACE_LINK_LIBRARIES Ogg::ogg Opus::opus FLAC::FLAC Vorbis::vorbis Vorbis::VorbisEnc)
    endif()
endif()