Debian Codegraph @

Xpjproject/cmake/FindSpeex.cmake

raw
1 find_package(PkgConfig QUIET)
2 if(PKG_CONFIG_FOUND)
3 pkg_search_module(PC_Speex QUIET speex libspeex)
4 endif()
5
6 find_path(Speex_INCLUDE_DIR
7 NAMES
8 "speex/speex.h"
9 HINTS
10 ${PC_Speex_INCLUDEDIR}
11 ${PC_Speex_INCLUDE_DIRS}
12 )
13 mark_as_advanced(Speex_INCLUDE_DIR)
14
15 find_library(Speex_LIBRARY
16 NAMES
17 speex
18 libspeex
19 HINTS
20 ${PC_Speex_LIBDIR}
21 ${PC_Speex_LIBRARY_DIRS}
22 )
23 mark_as_advanced(Speex_LIBRARY)
24
25 if(DEFINED PC_Speex_VERSION AND NOT PC_Speex_VERSION STREQUAL "")
26 set(Speex_VERSION "${PC_Speex_VERSION}")
27 elseif(Speex_INCLUDE_DIR)
28 cmake_path(APPEND _speex_header "${UPNP_INCLUDE_DIR}" speex.h)
29
30 if(IS_READABLE _speex_header)
31 include(Pj/GetMacroValue)
32 foreach(label in ITEMS major minor micro extra)
33 string(TOUPPER "SPEEX_LIB_GET_${label}_VERSION" macro)
34 pj_get_macro_value("${_speex_header}" "${macro}" "_speex_${label}")
35 endforeach()
36 unset(label)
37 unset(macro)
38
39 if (NOT _speex_major STREQUAL "" AND
40 NOT _speex_minor STREQUAL "" AND
41 NOT _speex_micro STREQUAL "")
42 set(_speex_version
43 "${_speex_major}.${_speex_minor}.${_speex_micro}" PARENT_SCOPE
44 )
45
46 if(NOT _speex_extra STREQUAL "")
47 set(_speex_version "${_speex_version}.${_speex_extra}")
48 endif()
49
50 set(SPEEX_VERSION "${_speex_version}")
51
52 unset(_speex_major)
53 unset(_speex_minor)
54 unset(_speex_micro)
55 unset(_speex_extra)
56 unset(_speex_version)
57 endif()
58 endif()
59
60 unset(_speex_header)
61 endif()
62 mark_as_advanced(Speex_VERSION)
63
64 include(FindPackageHandleStandardArgs)
65 find_package_handle_standard_args(Speex
66 REQUIRED_VARS
67 Speex_INCLUDE_DIR
68 Speex_LIBRARY
69 VERSION_VAR
70 Speex_VERSION
71 )
72
73 if(Speex_FOUND)
74 set(Speex_INCLUDE_DIRS ${Speex_INCLUDE_DIR})
75 set(Speex_LIBRARIES ${Speex_LIBRARY})
76 set(Speex_DEFINITIONS ${PC_Speex_CFLAGS_OTHER})
77
78 if(NOT TARGET Speex::Speex)
79 add_library(Speex::Speex UNKNOWN IMPORTED)
80 set_target_properties(Speex::Speex PROPERTIES
81 IMPORTED_LOCATION "${Speex_LIBRARIES}"
82 INTERFACE_INCLUDE_DIRECTORIES "${Speex_INCLUDE_DIRS}"
83 INTERFACE_COMPILE_OPTIONS "${Speex_DEFINITIONS}"
84 )
85 endif()
86 endif()