Codechange: replace "magic" trick with simpler straight forward code
[openttd-github.git] / cmake / FindFluidsynth.cmake
blob0ac4931d78d74a6e622b9e0ff023eee2b47a16e6
1 #[=======================================================================[.rst:
2 FindFluidsynth
3 -------
5 Finds the fluidsynth library.
7 Result Variables
8 ^^^^^^^^^^^^^^^^
10 This will define the following variables:
12 ``Fluidsynth_FOUND``
13   True if the system has the fluidsynth library.
14 ``Fluidsynth_INCLUDE_DIRS``
15   Include directories needed to use fluidsynth.
16 ``Fluidsynth_LIBRARIES``
17   Libraries needed to link to fluidsynth.
18 ``Fluidsynth_VERSION``
19   The version of the fluidsynth library which was found.
21 Cache Variables
22 ^^^^^^^^^^^^^^^
24 The following cache variables may also be set:
26 ``Fluidsynth_INCLUDE_DIR``
27   The directory containing ``fluidsynth.h``.
28 ``Fluidsynth_LIBRARY``
29   The path to the fluidsynth library.
31 #]=======================================================================]
33 find_package(PkgConfig QUIET)
34 pkg_check_modules(PC_Fluidsynth QUIET fluidsynth)
36 find_path(Fluidsynth_INCLUDE_DIR
37     NAMES fluidsynth.h
38     PATHS ${PC_Fluidsynth_INCLUDE_DIRS}
41 find_library(Fluidsynth_LIBRARY
42     NAMES fluidsynth
43     PATHS ${PC_Fluidsynth_LIBRARY_DIRS}
46 set(Fluidsynth_VERSION ${PC_Fluidsynth_VERSION})
48 include(FindPackageHandleStandardArgs)
49 find_package_handle_standard_args(Fluidsynth
50     FOUND_VAR Fluidsynth_FOUND
51     REQUIRED_VARS
52         Fluidsynth_LIBRARY
53         Fluidsynth_INCLUDE_DIR
54     VERSION_VAR Fluidsynth_VERSION
57 if(Fluidsynth_FOUND)
58     set(Fluidsynth_LIBRARIES ${Fluidsynth_LIBRARY})
59     set(Fluidsynth_INCLUDE_DIRS ${Fluidsynth_INCLUDE_DIR})
60 endif()
62 mark_as_advanced(
63     Fluidsynth_INCLUDE_DIR
64     Fluidsynth_LIBRARY