Support Sf2 Player, Mallets, PortAudio, and Lame with MSVC (#6507)

This commit is contained in:
Dominic Clark
2022-09-19 14:46:38 +01:00
committed by GitHub
parent 0b27497be2
commit 5bfd7fba4e
14 changed files with 374 additions and 249 deletions

View File

@@ -222,8 +222,12 @@ jobs:
set-env: ${{ matrix.arch == 'x86' }}
- name: Install dependencies
run: |
vcpkg install --triplet ${{ matrix.arch }}-windows --recurse `
fftw3 libsamplerate libsndfile lilv lv2 sdl2
vcpkg install `
--triplet=${{ matrix.arch }}-windows `
--host-triplet=${{ matrix.arch }}-windows `
--recurse `
fftw3 fluidsynth[sndfile] libsamplerate libsndfile libstk lilv lv2 `
portaudio sdl2
- name: Set up build environment
uses: ilammy/msvc-dev-cmd@d8610e2b41c6d0f0c3b4c46dad8df0fd826c68e1
with:

View File

@@ -22,6 +22,14 @@ ENDIF(COMMAND CMAKE_POLICY)
# Import of windows.h breaks min()/max()
ADD_DEFINITIONS(-DNOMINMAX)
# CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES is not set correctly for MinGW until
# CMake 3.14.1, so avoid specifying system include directories on affected
# versions. Normal include directories are safe, since GCC ignores them if they
# are already in the built-in search path.
if(MINGW AND CMAKE_VERSION VERSION_LESS "3.14.1")
set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)
endif()
INCLUDE(PluginList)
INCLUDE(CheckSubmodules)
INCLUDE(AddFileDependencies)
@@ -110,6 +118,7 @@ IF(LMMS_BUILD_WIN32)
SET(STATUS_ALSA "<not supported on this platform>")
SET(STATUS_PULSEAUDIO "<not supported on this platform>")
SET(STATUS_SOUNDIO "<disabled in this release>")
SET(STATUS_SNDIO "<not supported on this platform>")
SET(STATUS_WINMM "OK")
SET(STATUS_APPLEMIDI "<not supported on this platform>")
ELSE(LMMS_BUILD_WIN32)
@@ -297,17 +306,7 @@ ENDIF(WANT_CARLA)
# check for SDL2
IF(WANT_SDL)
# Don't look for SDL2main
SET(SDL2_BUILDING_LIBRARY TRUE)
# Search for SDL2 using config mode first, then fall back to module mode.
# This allows us to use SDL2's own CMake configuration files if available.
FIND_PACKAGE(SDL2 CONFIG QUIET)
IF(NOT TARGET SDL2::SDL2)
UNSET(SDL2_FOUND)
FIND_PACKAGE(SDL2 MODULE)
ENDIF()
FIND_PACKAGE(SDL2)
IF(SDL2_FOUND)
SET(LMMS_HAVE_SDL TRUE)
SET(LMMS_HAVE_SDL2 TRUE)
@@ -358,13 +357,13 @@ ENDIF(WANT_STK)
# check for PortAudio
IF(WANT_PORTAUDIO)
FIND_PACKAGE(Portaudio)
IF(PORTAUDIO_FOUND)
IF(Portaudio_FOUND)
SET(LMMS_HAVE_PORTAUDIO TRUE)
SET(STATUS_PORTAUDIO "OK")
ELSE(PORTAUDIO_FOUND)
ELSE()
SET(STATUS_PORTAUDIO "not found, please install portaudio19-dev (or similar, version >= 1.9) "
"if you require PortAudio support")
ENDIF(PORTAUDIO_FOUND)
ENDIF()
ENDIF(WANT_PORTAUDIO)
# check for libsoundio
@@ -496,14 +495,14 @@ ENDIF()
# check for Fluidsynth
IF(WANT_SF2)
PKG_CHECK_MODULES(FLUIDSYNTH fluidsynth>=1.0.7)
IF(FLUIDSYNTH_FOUND)
find_package(FluidSynth 1.0.7)
if(FluidSynth_FOUND)
SET(LMMS_HAVE_FLUIDSYNTH TRUE)
SET(STATUS_FLUIDSYNTH "OK")
ELSE(FLUIDSYNTH_FOUND)
else()
SET(STATUS_FLUIDSYNTH "not found, libfluidsynth-dev (or similar)"
"is highly recommended")
ENDIF(FLUIDSYNTH_FOUND)
endif()
ENDIF(WANT_SF2)
# check for libgig

View File

@@ -0,0 +1,73 @@
# Copyright (c) 2022 Dominic Clark
#
# Redistribution and use is allowed according to the terms of the New BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# Return if we already have FluidSynth
if(TARGET fluidsynth)
set(FluidSynth_FOUND 1)
return()
endif()
# Attempt to find FluidSynth using PkgConfig
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(FLUIDSYNTH_PKG fluidsynth)
endif()
# Find the library and headers using the results from PkgConfig as a guide
find_path(FluidSynth_INCLUDE_DIR
NAMES "fluidsynth.h"
HINTS ${FLUIDSYNTH_PKG_INCLUDE_DIRS}
)
find_library(FluidSynth_LIBRARY
NAMES "fluidsynth"
HINTS ${FLUIDSYNTH_PKG_LIBRARY_DIRS}
)
if(FluidSynth_INCLUDE_DIR AND FluidSynth_LIBRARY)
add_library(fluidsynth UNKNOWN IMPORTED)
set_target_properties(fluidsynth PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${FluidSynth_INCLUDE_DIR}"
)
if(VCPKG_INSTALLED_DIR)
include(ImportedTargetHelpers)
_get_vcpkg_library_configs(FluidSynth_IMPLIB_RELEASE FluidSynth_IMPLIB_DEBUG "${FluidSynth_LIBRARY}")
else()
set(FluidSynth_IMPLIB_RELEASE "${FluidSynth_LIBRARY}")
endif()
if(FluidSynth_IMPLIB_DEBUG)
set_target_properties(fluidsynth PROPERTIES
IMPORTED_LOCATION_RELEASE "${FluidSynth_IMPLIB_RELEASE}"
IMPORTED_LOCATION_DEBUG "${FluidSynth_IMPLIB_DEBUG}"
)
else()
set_target_properties(fluidsynth PROPERTIES
IMPORTED_LOCATION "${FluidSynth_IMPLIB_RELEASE}"
)
endif()
if(EXISTS "${FluidSynth_INCLUDE_DIR}/fluidsynth/version.h")
file(STRINGS
"${FluidSynth_INCLUDE_DIR}/fluidsynth/version.h"
_version_string
REGEX "^#[\t ]*define[\t ]+FLUIDSYNTH_VERSION[\t ]+\".*\""
)
string(REGEX REPLACE
"^.*FLUIDSYNTH_VERSION[\t ]+\"([^\"]*)\".*$"
"\\1"
FluidSynth_VERSION_STRING
"${_version_string}"
)
unset(_version_string)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FluidSynth
REQUIRED_VARS FluidSynth_LIBRARY FluidSynth_INCLUDE_DIR
VERSION_VAR FluidSynth_VERSION_STRING
)

View File

@@ -1,16 +1,37 @@
# - Try to find LAME
# Once done this will define
#
# LAME_FOUND - system has liblame
# LAME_INCLUDE_DIRS - the liblame include directory
# LAME_LIBRARIES - The liblame libraries
# Lame_FOUND - system has liblame
# Lame_INCLUDE_DIRS - the liblame include directory
# Lame_LIBRARIES - The liblame libraries
# mp3lame::mp3lame - an imported target providing lame
find_path(LAME_INCLUDE_DIRS lame/lame.h)
find_library(LAME_LIBRARIES mp3lame)
find_package(mp3lame CONFIG QUIET)
if(TARGET mp3lame::mp3lame)
# Extract details for find_package_handle_standard_args
get_target_property(Lame_LIBRARIES mp3lame::mp3lame LOCATION)
get_target_property(Lame_INCLUDE_DIRS mp3lame::mp3lame INTERFACE_INCLUDE_DIRECTORIES)
else()
find_path(Lame_INCLUDE_DIRS lame/lame.h)
find_library(Lame_LIBRARIES mp3lame)
list(APPEND Lame_DEFINITIONS HAVE_LIBMP3LAME=1)
mark_as_advanced(Lame_INCLUDE_DIRS Lame_LIBRARIES Lame_DEFINITIONS)
if(Lame_LIBRARIES AND Lame_INCLUDE_DIRS)
add_library(mp3lame::mp3lame UNKNOWN IMPORTED)
set_target_properties(mp3lame::mp3lame PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Lame_INCLUDE_DIRS}"
INTERFACE_COMPILE_DEFINITIONS "${Lame_DEFINITIONS}"
IMPORTED_LOCATION "${Lame_LIBRARIES}"
)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Lame DEFAULT_MSG LAME_INCLUDE_DIRS LAME_LIBRARIES)
list(APPEND LAME_DEFINITIONS -DHAVE_LIBMP3LAME=1)
mark_as_advanced(LAME_INCLUDE_DIRS LAME_LIBRARIES LAME_DEFINITIONS)
find_package_handle_standard_args(Lame
REQUIRED_VARS Lame_LIBRARIES Lame_INCLUDE_DIRS
)

View File

@@ -1,36 +1,44 @@
# - Try to find Portaudio
# Once done this will define
#
# PORTAUDIO_FOUND - system has Portaudio
# PORTAUDIO_INCLUDE_DIRS - the Portaudio include directory
# PORTAUDIO_LIBRARIES - Link these to use Portaudio
# PORTAUDIO_DEFINITIONS - Compiler switches required for using Portaudio
#
# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
# Copyright (c) 2022 Dominic Clark
#
# Redistribution and use is allowed according to the terms of the New BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# Try config mode if possible
find_package(portaudio CONFIG QUIET)
if (PORTAUDIO_LIBRARIES AND PORTAUDIO_INCLUDE_DIRS)
# in cache already
set(PORTAUDIO_FOUND TRUE)
else (PORTAUDIO_LIBRARIES AND PORTAUDIO_INCLUDE_DIRS)
include(FindPkgConfig)
pkg_check_modules(PORTAUDIO portaudio-2.0)
if (PORTAUDIO_FOUND)
if (NOT Portaudio_FIND_QUIETLY)
message(STATUS "Found Portaudio: ${PORTAUDIO_LIBRARIES}")
endif (NOT Portaudio_FIND_QUIETLY)
else (PORTAUDIO_FOUND)
if (Portaudio_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Portaudio")
endif (Portaudio_FIND_REQUIRED)
endif (PORTAUDIO_FOUND)
if(TARGET portaudio)
# Extract details for find_package_handle_standard_args
get_target_property(Portaudio_LIBRARY portaudio LOCATION)
get_target_property(Portaudio_INCLUDE_DIR portaudio INTERFACE_INCLUDE_DIRECTORIES)
else()
# Attempt to find PortAudio using PkgConfig, if we have it
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PORTAUDIO_PKG portaudio-2.0)
endif()
# show the PORTAUDIO_INCLUDE_DIRS and PORTAUDIO_LIBRARIES variables only in the advanced view
mark_as_advanced(PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES)
# Find the library and headers using the results from PkgConfig as a guide
find_library(Portaudio_LIBRARY
NAMES "portaudio"
HINTS ${PORTAUDIO_PKG_LIBRARY_DIRS}
)
endif (PORTAUDIO_LIBRARIES AND PORTAUDIO_INCLUDE_DIRS)
find_path(Portaudio_INCLUDE_DIR
NAMES "portaudio.h"
HINTS ${PORTAUDIO_PKG_INCLUDE_DIRS}
)
# Create an imported target for PortAudio if we succeeded in finding it.
if(Portaudio_LIBRARY AND Portaudio_INCLUDE_DIR)
add_library(portaudio UNKNOWN IMPORTED)
set_target_properties(portaudio PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Portaudio_INCLUDE_DIR}"
IMPORTED_LOCATION "${Portaudio_LIBRARY}"
)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Portaudio
REQUIRED_VARS Portaudio_LIBRARY Portaudio_INCLUDE_DIR
)

View File

@@ -1,60 +1,20 @@
# This module defines
# SDL2::SDL2, a target providing SDL2 itself
# SDL2::SDL2main, a target providing an entry point for applications
# SDL2_LIBRARY, the name of the library to link against
# SDL2_FOUND, if false, do not try to link to SDL2
# SDL2_INCLUDE_DIR, where to find SDL.h
#
# This module responds to the the flag:
# SDL2_BUILDING_LIBRARY
# If this is defined, then no SDL2::SDL2main target will be created because
# only applications need main().
# Otherwise, it is assumed you are building an application and this
# module will attempt to locate and set the the proper link flags
# as part of the SDL2::SDL2main target.
#
# Don't forget to include SDLmain.h and SDLmain.m your project for the
# OS X framework based version. (Other versions link to -lSDL2main which
# this module will try to find on your behalf.) Also for OS X, this
# module will automatically add the -framework Cocoa on your behalf.
#
#
# Additional Note: If you see an empty SDL2_LIBRARY in your configuration, it
# means CMake did not find your SDL2 library (SDL2.dll, libsdl2.so,
# SDL2.framework, etc).
# Set SDL2_LIBRARY to point to your SDL2 library, and configure again.
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
# as appropriate.
#
#
# Modified by Dominic Clark.
# Added modern CMake targets to match those SDL2 itself uses.
#
# $SDL2DIR is an environment variable that would
# correspond to the ./configure --prefix=$SDL2DIR
# used in building SDL2.
# l.e.galup 9-20-02
#
# Modified by Eric Wing.
# Added code to assist with automated building by using environmental variables
# and providing a more controlled/consistent search behavior.
# Added new modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
# Also corrected the header search path to follow "proper" SDL guidelines.
# Added a search for SDL2main which is needed by some platforms.
# Added a search for threads which is needed by some platforms.
# Added needed compile switches for MinGW.
#
# On OSX, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of
# SDL2_LIBRARY to override this selection or set the CMake environment
# CMAKE_INCLUDE_PATH to modify the search paths.
#
# Note that the header path has changed from SDL2/SDL.h to just SDL.h
# This needed to change because "proper" SDL convention
# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
# reasons because not all systems place things in SDL2/ (see FreeBSD).
# $SDL2DIR is an environment variable that would
# correspond to the ./configure --prefix=$SDL2DIR
# used in building SDL2.
#
# Modified by Eric Wing, l.e.galup, and Dominic Clark
#
#=============================================================================
# Copyright 2003-2009 Kitware, Inc.
#
@@ -68,110 +28,91 @@
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# message("<FindSDL2.cmake>")
# Try config mode first - anything SDL2 itself provides is likely to be more
# reliable than our guesses.
find_package(SDL2 CONFIG QUIET)
SET(SDL2_SEARCH_PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
${SDL2_PATH}
)
FIND_PATH(SDL2_INCLUDE_DIR SDL.h
HINTS
$ENV{SDL2DIR}
PATH_SUFFIXES SDL2 include/SDL2 include
PATHS ${SDL2_SEARCH_PATHS}
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PATH_SUFFIXES lib64 lib/x64 lib)
else()
set(PATH_SUFFIXES lib/x86 lib)
endif()
FIND_LIBRARY(SDL2_LIBRARY
NAMES SDL2
HINTS
$ENV{SDL2DIR}
PATH_SUFFIXES ${PATH_SUFFIXES}
PATHS ${SDL2_SEARCH_PATHS}
)
IF(NOT SDL2_BUILDING_LIBRARY)
IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
# Non-OS X framework versions expect you to also dynamically link to
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
# seem to provide SDL2main for compatibility even though they don't
# necessarily need it.
FIND_LIBRARY(SDL2MAIN_LIBRARY
NAMES SDL2main
HINTS
$ENV{SDL2DIR}
PATH_SUFFIXES ${PATH_SUFFIXES}
PATHS ${SDL2_SEARCH_PATHS}
)
ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
ENDIF(NOT SDL2_BUILDING_LIBRARY)
# SDL2 may require threads on your system.
# The Apple build may not need an explicit flag because one of the
# frameworks may already provide it.
# But for non-OSX systems, I will use the CMake Threads package.
IF(NOT APPLE)
FIND_PACKAGE(Threads)
ENDIF(NOT APPLE)
# MinGW needs an additional link flag, -mwindows
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows
IF(MINGW)
SET(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "mwindows for MinGW")
ENDIF(MINGW)
IF(SDL2_LIBRARY)
ADD_LIBRARY(SDL2::SDL2 UNKNOWN IMPORTED)
SET_TARGET_PROPERTIES(SDL2::SDL2 PROPERTIES
IMPORTED_LOCATION "${SDL2_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
if(TARGET SDL2::SDL2)
# Extract details for find_package_handle_standard_args
get_target_property(SDL2_LIBRARY SDL2::SDL2 LOCATION)
get_target_property(SDL2_INCLUDE_DIR SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)
else()
set(SDL2_SEARCH_PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
${SDL2_PATH}
)
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
IF(APPLE)
SET_PROPERTY(TARGET SDL2::SDL2 APPEND PROPERTY
INTERFACE_LINK_OPTIONS "-framework Cocoa"
)
ENDIF(APPLE)
# For threads, as mentioned Apple doesn't need this.
# In fact, there seems to be a problem if I used the Threads package
# and try using this line, so I'm just skipping it entirely for OS X.
IF(NOT APPLE AND Threads_FOUND)
SET_PROPERTY(TARGET SDL2::SDL2 APPEND PROPERTY
INTERFACE_LINK_LIBRARIES "Threads::Threads"
)
ENDIF(NOT APPLE AND Threads_FOUND)
ENDIF(SDL2_LIBRARY)
IF(NOT SDL2_BUILDING_LIBRARY AND SDL2MAIN_LIBRARY)
ADD_LIBRARY(SDL2::SDL2main STATIC IMPORTED)
SET_TARGET_PROPERTIES(SDL2::SDL2main PROPERTIES
IMPORTED_LOCATION "${SDL2MAIN_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
find_path(SDL2_INCLUDE_DIR
NAMES SDL.h
HINTS $ENV{SDL2DIR} ${SDL2_INCLUDE_DIRS}
PATH_SUFFIXES SDL2 include/SDL2 include
PATHS ${SDL2_SEARCH_PATHS}
)
IF(MINGW)
SET_PROPERTY(TARGET SDL2::SDL2main APPEND PROPERTY
INTERFACE_LINK_OPTIONS "${MINGW32_LIBRARY}"
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PATH_SUFFIXES lib64 lib/x64 lib)
else()
set(PATH_SUFFIXES lib/x86 lib)
endif()
find_library(SDL2_LIBRARY
NAMES SDL2
HINTS $ENV{SDL2DIR} ${SDL2_LIBDIR}
PATH_SUFFIXES ${PATH_SUFFIXES}
PATHS ${SDL2_SEARCH_PATHS}
)
# SDL2 may require threads on your system.
# The Apple build may not need an explicit flag because one of the
# frameworks may already provide it.
# But for non-OSX systems, I will use the CMake Threads package.
if(NOT APPLE)
find_package(Threads)
endif()
if(SDL2_LIBRARY AND SDL2_INCLUDE_DIR)
add_library(SDL2::SDL2 UNKNOWN IMPORTED)
set_target_properties(SDL2::SDL2 PROPERTIES
IMPORTED_LOCATION "${SDL2_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
)
ENDIF(MINGW)
ENDIF(NOT SDL2_BUILDING_LIBRARY AND SDL2MAIN_LIBRARY)
# message("</FindSDL2.cmake>")
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
if(APPLE)
set_property(TARGET SDL2::SDL2 APPEND PROPERTY
INTERFACE_LINK_OPTIONS "-framework Cocoa"
)
endif()
INCLUDE(FindPackageHandleStandardArgs)
# For threads, as mentioned Apple doesn't need this.
# In fact, there seems to be a problem if I used the Threads package
# and try using this line, so I'm just skipping it entirely for OS X.
if(NOT APPLE AND Threads_FOUND)
set_property(TARGET SDL2::SDL2 APPEND PROPERTY
INTERFACE_LINK_LIBRARIES "Threads::Threads"
)
endif()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
if(EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h")
file(READ "${SDL2_INCLUDE_DIR}/SDL_version.h" _sdl_version_h)
string(REGEX REPLACE ".*#[\t ]*define[\t ]+SDL_MAJOR_VERSION[\t ]+([0-9]+).*" "\\1" SDL2_VERSION_MAJOR "${_sdl_version_h}")
string(REGEX REPLACE ".*#[\t ]*define[\t ]+SDL_MINOR_VERSION[\t ]+([0-9]+).*" "\\1" SDL2_VERSION_MINOR "${_sdl_version_h}")
string(REGEX REPLACE ".*#[\t ]*define[\t ]+SDL_PATCHLEVEL[\t ]+([0-9]+).*" "\\1" SDL2_VERSION_PATCH "${_sdl_version_h}")
set(SDL2_VERSION "${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH}")
unset(_sdl_version_h)
endif()
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL2
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
VERSION_VAR SDL2_VERSION
)

View File

@@ -1,20 +1,32 @@
FIND_PATH(STK_INCLUDE_DIR Stk.h /usr/include/stk /usr/local/include/stk ${CMAKE_INSTALL_PREFIX}/include/stk ${CMAKE_FIND_ROOT_PATH}/include/stk)
# Try config mode first
find_package(unofficial-libstk CONFIG QUIET)
FIND_LIBRARY(STK_LIBRARY NAMES stk PATH /usr/lib /usr/local/lib ${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_FIND_ROOT_PATH}/lib)
if(TARGET unofficial::libstk::libstk)
# Extract details for find_package_handle_standard_args
get_target_property(STK_LIBRARY unofficial::libstk::libstk LOCATION)
get_target_property(STK_INCLUDE_DIR unofficial::libstk::libstk INTERFACE_INCLUDE_DIRECTORIES)
else()
find_path(STK_INCLUDE_DIR
NAMES stk/Stk.h
PATH /usr/include /usr/local/include "${CMAKE_INSTALL_PREFIX}/include" "${CMAKE_FIND_ROOT_PATH}/include"
)
IF (STK_INCLUDE_DIR AND STK_LIBRARY)
SET(STK_FOUND TRUE)
ENDIF (STK_INCLUDE_DIR AND STK_LIBRARY)
find_library(STK_LIBRARY
NAMES stk
PATH /usr/lib /usr/local/lib "${CMAKE_INSTALL_PREFIX}/lib" "${CMAKE_FIND_ROOT_PATH}/lib"
)
if(STK_INCLUDE_DIR AND STK_LIBRARY)
# Yes, this target name is hideous, but it matches that provided by vcpkg
add_library(unofficial::libstk::libstk UNKNOWN IMPORTED)
set_target_properties(unofficial::libstk::libstk PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${STK_INCLUDE_DIR}"
IMPORTED_LOCATION "${STK_LIBRARY}"
)
endif()
endif()
IF (STK_FOUND)
IF (NOT STK_FIND_QUIETLY)
MESSAGE(STATUS "Found STK: ${STK_LIBRARY}")
SET(HAVE_STK TRUE)
ENDIF (NOT STK_FIND_QUIETLY)
ELSE (STK_FOUND)
IF (STK_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find STK")
ENDIF (STK_FIND_REQUIRED)
ENDIF (STK_FOUND)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(STK
REQUIRED_VARS STK_LIBRARY STK_INCLUDE_DIR
)

View File

@@ -0,0 +1,57 @@
# Given a library in vcpkg, find appropriate debug and release versions. If only
# one version exists, it is used as the release version, and the debug version
# is not set.
function(_get_vcpkg_library_configs _release_out _debug_out _library)
# We want to do all operations within the vcpkg directory
file(RELATIVE_PATH _lib_relative "${VCPKG_INSTALLED_DIR}" "${_library}")
# Return early if we're not using vcpkg
if(IS_ABSOLUTE _lib_relative OR _lib_relative MATCHES "^\\.\\./")
set("${_release_out}" "${_library}" PARENT_SCOPE)
return()
endif()
string(REPLACE "/" ";" _path_bits "${_lib_relative}")
# Determine whether we were given the debug or release version
list(FIND _path_bits "debug" _debug_index)
if(_debug_index EQUAL -1)
# We have the release version, so use it
set(_release_lib "${_library}")
# Try to find a debug version too
list(FIND _path_bits "lib" _lib_index)
if(_lib_index GREATER_EQUAL 0)
list(INSERT _path_bits "${_lib_index}" "debug")
list(INSERT _path_bits 0 "${VCPKG_INSTALLED_DIR}")
string(REPLACE ";" "/" _debug_lib "${_path_bits}")
if(NOT EXISTS "${_debug_lib}")
# Debug version does not exist - only use given version
unset(_debug_lib)
endif()
endif()
else()
# We have the debug version, so try to find a release version too
list(REMOVE_AT _path_bits "${_debug_index}")
list(INSERT _path_bits 0 "${VCPKG_INSTALLED_DIR}")
string(REPLACE ";" "/" _release_lib "${_path_bits}")
if(NOT EXISTS "${_release_lib}")
# Release version does not exist - only use given version
set(_release_lib "${_library}")
else()
# Release version exists, so use given version as debug
set(_debug_lib "${_library}")
endif()
endif()
# Set output variables appropriately
if(_debug_lib)
set("${_release_out}" "${_release_lib}" PARENT_SCOPE)
set("${_debug_out}" "${_debug_lib}" PARENT_SCOPE)
else()
set("${_release_out}" "${_release_lib}" PARENT_SCOPE)
unset("${_debug_out}" PARENT_SCOPE)
endif()
endfunction()

View File

@@ -1,8 +1,13 @@
if(LMMS_HAVE_FLUIDSYNTH)
INCLUDE(BuildPlugin)
INCLUDE_DIRECTORIES(${FLUIDSYNTH_INCLUDE_DIRS} ${SAMPLERATE_INCLUDE_DIRS})
LINK_DIRECTORIES(${FLUIDSYNTH_LIBRARY_DIRS} ${SAMPLERATE_LIBRARY_DIRS})
LINK_LIBRARIES(${FLUIDSYNTH_LIBRARIES} ${SAMPLERATE_LIBRARIES})
BUILD_PLUGIN(sf2player Sf2Player.cpp Sf2Player.h PatchesDialog.cpp PatchesDialog.h PatchesDialog.ui MOCFILES Sf2Player.h PatchesDialog.h UICFILES PatchesDialog.ui EMBEDDED_RESOURCES *.png)
endif(LMMS_HAVE_FLUIDSYNTH)
include(BuildPlugin)
include_directories(${SAMPLERATE_INCLUDE_DIRS})
link_directories(${SAMPLERATE_LIBRARY_DIRS})
link_libraries(${SAMPLERATE_LIBRARIES})
build_plugin(sf2player
Sf2Player.cpp Sf2Player.h PatchesDialog.cpp PatchesDialog.h PatchesDialog.ui
MOCFILES Sf2Player.h PatchesDialog.h
UICFILES PatchesDialog.ui
EMBEDDED_RESOURCES *.png
)
target_link_libraries(sf2player fluidsynth)
endif()

View File

@@ -282,7 +282,7 @@ void Sf2Instrument::loadFile( const QString & _file )
fluid_preset_t preset;
fluid_preset_t *pCurPreset = &preset;
#else
fluid_preset_t *pCurPreset;
fluid_preset_t *pCurPreset = nullptr;
#endif
if ( ( pCurPreset = fluid_sfont_iteration_next_wrapper( pSoundFont, pCurPreset ) ) ) {
@@ -475,7 +475,7 @@ QString Sf2Instrument::getCurrentPatchName()
fluid_preset_t preset;
fluid_preset_t *pCurPreset = &preset;
#else
fluid_preset_t *pCurPreset;
fluid_preset_t *pCurPreset = nullptr;
#endif
while ((pCurPreset = fluid_sfont_iteration_next_wrapper(pSoundFont, pCurPreset)))
{
@@ -676,8 +676,13 @@ void Sf2Instrument::noteOn( Sf2PluginData * n )
// get list of current voice IDs so we can easily spot the new
// voice after the fluid_synth_noteon() call
const int poly = fluid_synth_get_polyphony( m_synth );
fluid_voice_t * voices[poly];
#ifndef _MSC_VER
fluid_voice_t* voices[poly];
unsigned int id[poly];
#else
const auto voices = static_cast<fluid_voice_t**>(_alloca(poly * sizeof(fluid_voice_t*)));
const auto id = static_cast<unsigned int*>(_alloca(poly * sizeof(unsigned int)));
#endif
fluid_synth_get_voicelist( m_synth, voices, poly, -1 );
for( int i = 0; i < poly; ++i )
{

View File

@@ -1,5 +1,7 @@
INCLUDE(BuildPlugin)
INCLUDE_DIRECTORIES("${STK_INCLUDE_DIR}")
LINK_LIBRARIES(${STK_LIBRARY})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
BUILD_PLUGIN(malletsstk Mallets.cpp Mallets.h MOCFILES Mallets.h EMBEDDED_RESOURCES artwork.png logo.png)
include(BuildPlugin)
build_plugin(malletsstk
Mallets.cpp Mallets.h
MOCFILES Mallets.h
EMBEDDED_RESOURCES artwork.png logo.png
)
target_link_libraries(malletsstk unofficial::libstk::libstk)

View File

@@ -30,9 +30,9 @@
#include <QDomElement>
#include <QMessageBox>
#include "BandedWG.h"
#include "ModalBar.h"
#include "TubeBell.h"
#include <stk/BandedWG.h>
#include <stk/ModalBar.h>
#include <stk/TubeBell.h>
#include "AudioEngine.h"
#include "ConfigManager.h"

View File

@@ -27,7 +27,7 @@
#ifndef _MALLET_H
#define _MALLET_H
#include "Instrmnt.h"
#include <stk/Instrmnt.h>
#include "ComboBox.h"
#include "Instrument.h"

View File

@@ -55,7 +55,7 @@ ADD_GEN_QRC(LMMS_RCC_OUT lmms.qrc
# Paths relative to lmms executable
FILE(RELATIVE_PATH LIB_DIR_RELATIVE "/${BIN_DIR}" "/${LIB_DIR}")
FILE(RELATIVE_PATH PLUGIN_DIR_RELATIVE "/${BIN_DIR}" "/${PLUGIN_DIR}")
ADD_DEFINITIONS(-DLIB_DIR="${LIB_DIR_RELATIVE}" -DPLUGIN_DIR="${PLUGIN_DIR_RELATIVE}" ${PULSEAUDIO_DEFINITIONS} ${PORTAUDIO_DEFINITIONS})
ADD_DEFINITIONS(-DLIB_DIR="${LIB_DIR_RELATIVE}" -DPLUGIN_DIR="${PLUGIN_DIR_RELATIVE}" ${PULSEAUDIO_DEFINITIONS})
INCLUDE_DIRECTORIES(
${JACK_INCLUDE_DIRS}
${SAMPLERATE_INCLUDE_DIRS}
@@ -75,10 +75,6 @@ IF(LMMS_HAVE_WEAKJACK)
ADD_DEFINITIONS(-DUSE_WEAK_JACK=1 -DNO_JACK_METADATA=1)
ENDIF()
IF(NOT ("${PORTAUDIO_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${PORTAUDIO_INCLUDE_DIR}")
ENDIF()
IF(NOT ("${PULSEAUDIO_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${PULSEAUDIO_INCLUDE_DIR}")
ENDIF()
@@ -87,10 +83,6 @@ IF(NOT ("${OGGVORBIS_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${OGGVORBIS_INCLUDE_DIR}")
ENDIF()
IF(NOT ("${LAME_INCLUDE_DIRS}" STREQUAL ""))
INCLUDE_DIRECTORIES("${LAME_INCLUDE_DIRS}")
ENDIF()
IF(NOT ("${LV2_INCLUDE_DIRS}" STREQUAL ""))
INCLUDE_DIRECTORIES(${LV2_INCLUDE_DIRS})
ENDIF()
@@ -170,19 +162,25 @@ if(LMMS_HAVE_LIBRT)
list(APPEND EXTRA_LIBRARIES "rt")
endif()
if(LMMS_HAVE_PORTAUDIO)
list(APPEND EXTRA_LIBRARIES portaudio)
endif()
if(LMMS_HAVE_MP3LAME)
list(APPEND EXTRA_LIBRARIES mp3lame::mp3lame)
endif()
SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS}
${CMAKE_THREAD_LIBS_INIT}
${QT_LIBRARIES}
${ASOUND_LIBRARY}
${SDL_LIBRARY}
${SDL2_LIBRARY}
${PORTAUDIO_LIBRARIES}
${SOUNDIO_LIBRARY}
${SNDIO_LIBRARIES}
${PULSEAUDIO_LIBRARIES}
${JACK_LIBRARIES}
${OGGVORBIS_LIBRARIES}
${LAME_LIBRARIES}
${LV2_LIBRARIES}
${SUIL_LIBRARIES}
${LILV_LIBRARIES}