Debian Codegraph @

cmake/FindFLAC.cmake

raw
1 # - Find FLAC
2 # Find the native FLAC includes and libraries
3 #
4 # FLAC_INCLUDE_DIR - where to find FLAC headers.
5 # FLAC_LIBRARIES - List of libraries when using libFLAC.
6 # FLAC_FOUND - True if libFLAC found.
7
8 if(FLAC_INCLUDE_DIR)
9 # Already in cache, be silent
10 set(FLAC_FIND_QUIETLY TRUE)
11 endif()
12
13 find_path(FLAC_INCLUDE_DIR FLAC/stream_decoder.h)
14
15 # MSVC built libraries can name them *_static, which is good as it
16 # distinguishes import libraries from static libraries with the same extension.
17 find_library(FLAC_LIBRARY NAMES FLAC libFLAC libFLAC_dynamic libFLAC_static)
18 find_library(OGG_LIBRARY NAMES ogg ogg_static libogg libogg_static)
19
20 # Handle the QUIETLY and REQUIRED arguments and set FLAC_FOUND to TRUE if
21 # all listed variables are TRUE.
22 include(FindPackageHandleStandardArgs)
23 find_package_handle_standard_args(FLAC
24 DEFAULT_MSG
25 FLAC_INCLUDE_DIR OGG_LIBRARY FLAC_LIBRARY
26 )
27
28 if(FLAC_FOUND)
29 set(FLAC_LIBRARIES ${FLAC_LIBRARY} ${OGG_LIBRARY})
30 if(WIN32)
31 set(FLAC_LIBRARIES ${FLAC_LIBRARIES} wsock32)
32 endif()
33 else()
34 set(FLAC_LIBRARIES)
35 endif()
36
37 mark_as_advanced(
38 FLAC_INCLUDE_DIR
39 FLAC_LIBRARY
40 )
41
42 if(FLAC_FOUND AND NOT TARGET FLAC::FLAC)
43 add_library(FLAC::FLAC UNKNOWN IMPORTED)
44 set_target_properties(FLAC::FLAC PROPERTIES
45 IMPORTED_LOCATION "${FLAC_LIBRARY}"
46 INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}"
47 )
48 if(WIN32)
49 set_target_properties(FLAC::FLAC PROPERTIES
50 INTERFACE_LINK_LIBRARIES "${OGG_LIBRARY};wsock32"
51 )
52 else()
53 set_target_properties(FLAC::FLAC PROPERTIES
54 INTERFACE_LINK_LIBRARIES "${OGG_LIBRARY}"
55 )
56 endif()
57 endif()