File: FindFLAC.cmake

package info (click to toggle)
libsndfile 1.2.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,180 kB
  • sloc: ansic: 55,354; cpp: 1,108; python: 791; makefile: 545; sh: 538; cs: 122
file content (67 lines) | stat: -rw-r--r-- 1,659 bytes parent folder | download | duplicates (4)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# - Find FLAC
# Find the native FLAC includes and libraries
#
#  FLAC_INCLUDE_DIRS - where to find FLAC headers.
#  FLAC_LIBRARIES    - List of libraries when using libFLAC.
#  FLAC_FOUND        - True if libFLAC found.
#  FLAC_DEFINITIONS  - FLAC compile definitons 

if (FLAC_INCLUDE_DIR)
    # Already in cache, be silent
    set (FLAC_FIND_QUIETLY TRUE)
endif ()

find_package (Ogg QUIET)

find_package (PkgConfig QUIET)
pkg_check_modules(PC_FLAC QUIET flac)

set(FLAC_VERSION ${PC_FLAC_VERSION})

find_path (FLAC_INCLUDE_DIR FLAC/stream_decoder.h
	HINTS
		${PC_FLAC_INCLUDEDIR}
		${PC_FLAC_INCLUDE_DIRS}
		${FLAC_ROOT}
	)

# MSVC built libraries can name them *_static, which is good as it
# distinguishes import libraries from static libraries with the same extension.
find_library (FLAC_LIBRARY
	NAMES
		FLAC
		libFLAC
		libFLAC_dynamic
		libFLAC_static
	HINTS
		${PC_FLAC_LIBDIR}
		${PC_FLAC_LIBRARY_DIRS}
		${FLAC_ROOT}
	)

# Handle the QUIETLY and REQUIRED arguments and set FLAC_FOUND to TRUE if
# all listed variables are TRUE.
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (FLAC
	REQUIRED_VARS
		FLAC_LIBRARY
		FLAC_INCLUDE_DIR
		Ogg_FOUND
	VERSION_VAR
        FLAC_VERSION
	)

if (FLAC_FOUND)
	set (FLAC_INCLUDE_DIRS ${FLAC_INCLUDE_DIR})
	set (FLAC_LIBRARIES ${FLAC_LIBRARY} ${OGG_LIBRARIES})
    if (NOT TARGET FLAC::FLAC)
		add_library(FLAC::FLAC UNKNOWN IMPORTED)
		set_target_properties(FLAC::FLAC PROPERTIES
			INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}"
			IMPORTED_LOCATION "${FLAC_LIBRARY}"
			INTERFACE_LINK_LIBRARIES Ogg::ogg
			)
	endif ()
endif ()

mark_as_advanced(FLAC_INCLUDE_DIR FLAC_LIBRARY)