Debian Codegraph @

prboom2/cmake/FindFluidSynth.cmake

raw
1 #[=======================================================================[.rst:
2 FindFluidSynth
3 -------
4
5 Finds the FluidSynth library.
6
7 Imported Targets
8 ^^^^^^^^^^^^^^^^
9
10 This module provides the following imported targets, if found:
11
12 ``FluidSynth::libfluidsynth``
13 The FluidSynth library
14
15 Result Variables
16 ^^^^^^^^^^^^^^^^
17
18 This will define the following variables:
19
20 ``FluidSynth_FOUND``
21 True if the system has the FluidSynth library.
22 ``FluidSynth_INCLUDE_DIRS``
23 Include directories needed to use FluidSynth.
24 ``FluidSynth_LIBRARIES``
25 Libraries needed to link to FluidSynth.
26
27 Cache Variables
28 ^^^^^^^^^^^^^^^
29
30 The following cache variables may also be set:
31
32 ``FluidSynth_INCLUDE_DIR``
33 The directory containing ``FluidSynth.h``.
34 ``FluidSynth_DLL``
35 The path to the FluidSynth Windows runtime.
36 ``FluidSynth_LIBRARY``
37 The path to the FluidSynth library.
38
39 #]=======================================================================]
40
41 find_package(PkgConfig QUIET)
42 pkg_check_modules(PC_fluidsynth IMPORTED_TARGET fluidsynth)
43
44 if(PC_fluidsynth_FOUND)
45 if(NOT TARGET FluidSynth::libfluidsynth)
46 add_library(FluidSynth::libfluidsynth ALIAS PkgConfig::PC_fluidsynth)
47 endif()
48 set(FluidSynth_FOUND TRUE)
49 set(FluidSynth_VERSION ${PC_fluidsynth_VERSION})
50 return()
51 endif()
52
53 find_path(
54 FluidSynth_INCLUDE_DIR
55 NAMES fluidsynth.h
56 )
57
58 find_file(
59 FluidSynth_DLL
60 NAMES fluidsynth.dll libfluidsynth.dll libfluidsynth-3.dll
61 PATH_SUFFIXES bin
62 )
63
64 find_library(
65 FluidSynth_LIBRARY
66 NAMES fluidsynth libfluidsynth fluidsynth-3 libfluidsynth-3
67 )
68
69 if(FluidSynth_DLL OR FluidSynth_LIBRARY MATCHES ".so|.dylib")
70 set(_fluidsynth_library_type SHARED)
71 else()
72 set(_fluidsynth_library_type STATIC)
73 endif()
74
75 include(FindPackageHandleStandardArgs)
76 find_package_handle_standard_args(
77 FluidSynth
78 REQUIRED_VARS "FluidSynth_LIBRARY" "FluidSynth_INCLUDE_DIR")
79
80 if(FluidSynth_FOUND)
81 if(NOT TARGET FluidSynth::libfluidsynth)
82 add_library(FluidSynth::libfluidsynth ${_fluidsynth_library_type} IMPORTED)
83 set_target_properties(
84 FluidSynth::libfluidsynth
85 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FluidSynth_INCLUDE_DIR}"
86 )
87 endif()
88
89 if(FluidSynth_DLL)
90 set_target_properties(
91 FluidSynth::libfluidsynth
92 PROPERTIES IMPORTED_LOCATION "${FluidSynth_DLL}"
93 IMPORTED_IMPLIB "${FluidSynth_LIBRARY}"
94 )
95 else()
96 set_target_properties(
97 FluidSynth::libfluidsynth
98 PROPERTIES IMPORTED_LOCATION "${FluidSynth_LIBRARY}"
99 )
100 endif()
101
102 set(FluidSynth_LIBRARIES FluidSynth::libfluidsynth)
103 set(FluidSynth_INCLUDE_DIRS "${FluidSynth_INCLUDE_DIR}")
104 endif()
105
106 mark_as_advanced(
107 FluidSynth_INCLUDE_DIR
108 FluidSynth_DLL
109 FluidSynth_LIBRARY
110 )