Debian Codegraph @

cmake/FindFLAC.cmake

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