Commit b49f3bd0 authored by Christophe Giboudeaux's avatar Christophe Giboudeaux

Create FindFluidSynth.cmake.

Summary:
Minuet can use FluidSynth on !android platforms. Let's add a FindFluidSynth
module to do things properly.

Subscribers: #kde_edu

Tags: #kde_edu

Differential Revision: https://phabricator.kde.org/D11095
parent f1bab8d0
......@@ -15,7 +15,7 @@ set(ECM_MIN_VERSION "5.15.0")
set(QT_MIN_VERSION "5.7.0")
find_package(ECM ${ECM_MIN_VERSION} CONFIG REQUIRED)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${minuet_SOURCE_DIR}/cmake)
include(GenerateExportHeader)
include(ECMSetupVersion)
......@@ -45,8 +45,14 @@ IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
CoreAddons
I18n
Crash
DocTools
DocTools
)
find_package(FluidSynth 1.1.6)
set_package_properties(FluidSynth PROPERTIES
TYPE OPTIONAL
PURPOSE "Needed if you want to build the fluidsynth sound controller"
)
ENDIF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
......
#.rst:
# FindFluidSynth
# ---------
#
# Try to find the FluidSynth library.
#
# This will define the following variables:
#
# ``FluidSynth_FOUND``
# System has FluidSynth.
#
# ``FluidSynth_VERSION``
# The version of FluidSynth.
#
# ``FluidSynth_INCLUDE_DIRS``
# This should be passed to target_include_directories() if
# the target is not used for linking.
#
# ``FluidSynth_LIBRARIES``
# The FluidSynth library.
# This can be passed to target_link_libraries() instead of
# the ``FluidSynth::FluidSynth`` target
#
# If ``FluidSynth_FOUND`` is TRUE, the following imported target
# will be available:
#
# ``FluidSynth::FluidSynth``
# The FluidSynth library
#
#=============================================================================
# Copyright 2018 Christophe Giboudeaux <christophe@krop.fr>
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
if(NOT ${FluidSynth_FIND_VERSION})
set(FluidSynth_FIND_VERSION "1.1.6")
endif()
find_package(PkgConfig QUIET)
pkg_check_modules(PC_FluidSynth QUIET fluidsynth>=${FluidSynth_FIND_VERSION})
find_library(FluidSynth_LIBRARIES
NAMES fluidsynth
HINTS ${PC_FluidSynth_LIBDIR}
)
find_path(FluidSynth_INCLUDE_DIRS
NAMES fluidsynth.h
HINTS ${PC_FluidSynth_INCLUDEDIR}
)
#set(FluidSynth_VERSION "${PC_FluidSynth_VERSION}")
if(NOT FluidSynth_VERSION)
if(EXISTS "${FluidSynth_INCLUDE_DIRS}/fluidsynth/version.h")
file(STRINGS "${FluidSynth_INCLUDE_DIRS}/fluidsynth/version.h" _FLUIDSYNTH_VERSION_H
REGEX "^#define[ ]+FLUIDSYNTH_VERSION[ ]+\"[0-9].[0-9].[0-9]\"")
string(REGEX REPLACE "^#define[ ]+FLUIDSYNTH_VERSION[ ]+\"([0-9].[0-9].[0-9])\".*" "\\1" FluidSynth_VERSION "${_FLUIDSYNTH_VERSION_H}")
unset(_FLUIDSYNTH_VERSION_H)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FluidSynth
FOUND_VAR FluidSynth_FOUND
REQUIRED_VARS FluidSynth_LIBRARIES FluidSynth_INCLUDE_DIRS
VERSION_VAR FluidSynth_VERSION
)
if(FluidSynth_FOUND AND NOT TARGET FluidSynth::FluidSynth)
add_library(FluidSynth::FluidSynth UNKNOWN IMPORTED)
set_target_properties(FluidSynth::FluidSynth PROPERTIES
IMPORTED_LOCATION "${FluidSynth_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${FluidSynth_INCLUDE_DIRS}"
)
endif()
include(FeatureSummary)
set_package_properties(FluidSynth PROPERTIES
URL "http://www.fluidsynth.org/"
DESCRIPTION "A SoundFont Synthesizer"
)
IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
find_package(PkgConfig REQUIRED)
if(PKG_CONFIG_FOUND)
message(STATUS "Program pkg-config found (${PKG_CONFIG_EXECUTABLE})")
else()
message(FATAL_ERROR "Program pkg-config not found")
endif()
pkg_check_modules(PC_FLUIDSYNTH REQUIRED fluidsynth>=1.1.6)
if(NOT PC_FLUIDSYNTH_FOUND)
message(WARNING "Please install fluidsynth libraries and headers (package fluidsynth) if you want to build fluidsynth soundcontroller")
endif()
if(PC_FLUIDSYNTH_FOUND)
find_library(FLUIDSYNTH_LIBRARIES
NAMES fluidsynth
HINTS ${PC_FLUIDSYNTH_LIBDIR}
)
find_path(FLUIDSYNTH_INCLUDE_DIRS
NAMES fluidsynth.h
HINTS ${PC_FLUIDSYNTH_INCLUDEDIR}
)
add_subdirectory(fluidsynthsoundcontroller)
endif()
ENDIF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Android")
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android" AND FluidSynth_FOUND)
add_subdirectory(fluidsynthsoundcontroller)
else()
add_subdirectory(csoundsoundcontroller)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Android")
endif()
include_directories(${FLUIDSYNTH_INCLUDE_DIRS})
set(fluidsynthsoundcontroller_PLUGIN_SRCS
fluidsynthsoundcontroller.cpp
)
......@@ -9,7 +7,7 @@ add_library(minuetfluidsynthsoundcontroller MODULE ${fluidsynthsoundcontroller_P
target_link_libraries(minuetfluidsynthsoundcontroller
Qt5::Core
Minuet::Interfaces
${FLUIDSYNTH_LIBRARIES}
FluidSynth::FluidSynth
)
IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment