Debian Codegraph @

cmake/modules/avcodecs/FindFLAC.cmake

raw
1 # Sourced from libsndfile:
2 # https://github.com/libsndfile/libsndfile
3 #
4 # - Find FLAC
5 # Find the native FLAC includes and libraries
6 #
7 # FLAC_INCLUDE_DIRS - where to find FLAC headers.
8 # FLAC_LIBRARIES - List of libraries when using libFLAC.
9 # FLAC_FOUND - True if libFLAC found.
10 # FLAC_DEFINITIONS - FLAC compile definitons
11
12 if (FLAC_INCLUDE_DIR)
13 # Already in cache, be silent
14 set (FLAC_FIND_QUIETLY TRUE)
15 endif ()
16
17 find_package (Ogg QUIET)
18
19 find_package (PkgConfig QUIET)
20 pkg_check_modules(PC_FLAC QUIET flac)
21
22 set(FLAC_VERSION ${PC_FLAC_VERSION})
23
24 find_path (FLAC_INCLUDE_DIR FLAC/stream_decoder.h
25 HINTS
26 ${PC_FLAC_INCLUDEDIR}
27 ${PC_FLAC_INCLUDE_DIRS}
28 ${FLAC_ROOT}
29 )
30
31 # MSVC built libraries can name them *_static, which is good as it
32 # distinguishes import libraries from static libraries with the same extension.
33 find_library (FLAC_LIBRARY
34 NAMES
35 FLAC
36 libFLAC
37 libFLAC_dynamic
38 libFLAC_static
39 HINTS
40 ${PC_FLAC_LIBDIR}
41 ${PC_FLAC_LIBRARY_DIRS}
42 ${FLAC_ROOT}
43 )
44
45 # Handle the QUIETLY and REQUIRED arguments and set FLAC_FOUND to TRUE if
46 # all listed variables are TRUE.
47 include (FindPackageHandleStandardArgs)
48 find_package_handle_standard_args (FLAC
49 REQUIRED_VARS
50 FLAC_LIBRARY
51 FLAC_INCLUDE_DIR
52 Ogg_FOUND
53 VERSION_VAR
54 FLAC_VERSION
55 )
56
57 if (FLAC_FOUND)
58 set (FLAC_INCLUDE_DIRS ${FLAC_INCLUDE_DIR})
59 set (FLAC_LIBRARIES ${FLAC_LIBRARY} ${OGG_LIBRARIES})
60 if (NOT TARGET FLAC::FLAC)
61 add_library(FLAC::FLAC UNKNOWN IMPORTED)
62 set_target_properties(FLAC::FLAC PROPERTIES
63 INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}"
64 IMPORTED_LOCATION "${FLAC_LIBRARY}"
65 INTERFACE_LINK_LIBRARIES Ogg::ogg
66 )
67 endif ()
68 endif ()
69
70 mark_as_advanced(FLAC_INCLUDE_DIR FLAC_LIBRARY)