mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 19:38:06 -04:00
add PkgConfigHelper.cmake, update FindFluidSynth.cmake
This commit is contained in:
parent
5156ef30e9
commit
8f214e167f
1
.github/workflows/main.yml
vendored
1
.github/workflows/main.yml
vendored
@ -7,6 +7,7 @@ on:
|
||||
paths-ignore: ['**.md']
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
paths-ignore: ['**.md']
|
||||
|
||||
jobs:
|
||||
linux64:
|
||||
|
17
.github/workflows/win_msvc.yml
vendored
17
.github/workflows/win_msvc.yml
vendored
@ -7,6 +7,7 @@ on:
|
||||
paths-ignore: ['**.md']
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
paths-ignore: ['**.md']
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
@ -20,11 +21,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
conf:
|
||||
- arch: 'x86'
|
||||
vars: '32'
|
||||
- arch: 'x64'
|
||||
vars: '64'
|
||||
arch: [x64, x86]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@ -48,14 +45,18 @@ jobs:
|
||||
"$nuget" setapikey "${{ secrets.GITHUB_TOKEN }}" \
|
||||
-source "$source_url"
|
||||
|
||||
- name: Setup devcmd
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: ${{ matrix.arch }}
|
||||
|
||||
- name: Configure
|
||||
shell: cmd
|
||||
run: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars${{ matrix.conf.vars }}.bat"
|
||||
cmake -B build -G Ninja `
|
||||
-DCMAKE_BUILD_TYPE=Release -DENABLE_WERROR=ON `
|
||||
-DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" `
|
||||
-DVCPKG_TARGET_TRIPLET="${{ matrix.conf.arch }}-windows-static-release" `
|
||||
-DVCPKG_TARGET_TRIPLET="${{ matrix.arch }}-windows-static-release" `
|
||||
-DVCPKG_OVERLAY_TRIPLETS="cmake/triplets"
|
||||
|
||||
- name: Build
|
||||
@ -69,7 +70,7 @@ jobs:
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Win-${{ matrix.conf.arch }}
|
||||
name: Win-${{ matrix.arch }}
|
||||
path: build/*.zip
|
||||
|
||||
- name: Extract Version Number
|
||||
|
@ -61,16 +61,26 @@ check_symbol_exists(strsignal "string.h" HAVE_STRSIGNAL)
|
||||
check_symbol_exists(strcasecmp "strings.h" HAVE_DECL_STRCASECMP)
|
||||
check_symbol_exists(strncasecmp "strings.h" HAVE_DECL_STRNCASECMP)
|
||||
|
||||
include(PkgConfigHelper)
|
||||
|
||||
option(CMAKE_FIND_PACKAGE_PREFER_CONFIG
|
||||
"Lookup package config files before using find modules" ON)
|
||||
|
||||
if(VCPKG_TOOLCHAIN)
|
||||
set(ENV{PKG_CONFIG_PATH} "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/pkgconfig")
|
||||
endif()
|
||||
|
||||
# Library requirements.
|
||||
find_package(SDL2 2.0.18 REQUIRED)
|
||||
find_package(SDL2_net REQUIRED)
|
||||
find_package(OpenAL REQUIRED)
|
||||
find_package(SndFile REQUIRED)
|
||||
|
||||
find_package(FluidSynth)
|
||||
if(NOT TARGET SDL2_net::SDL2_net)
|
||||
add_library(SDL2_net::SDL2_net ALIAS SDL2_net::SDL2_net-static)
|
||||
endif()
|
||||
|
||||
find_package(FluidSynth 2.2.0)
|
||||
find_package(libxmp)
|
||||
|
||||
# Python 3
|
||||
|
@ -1,106 +1,110 @@
|
||||
# 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::libfluidsynth`` target
|
||||
#
|
||||
# If ``FluidSynth_FOUND`` is TRUE, the following imported target
|
||||
# will be available:
|
||||
#
|
||||
# ``FluidSynth::libfluidsynth``
|
||||
# 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.
|
||||
#=============================================================================
|
||||
#[=======================================================================[.rst:
|
||||
FindFluidSynth
|
||||
-------
|
||||
|
||||
# Cache variable that allows you to point CMake at a directory containing
|
||||
# an extracted development library.
|
||||
set(FluidSynth_DIR "${FluidSynth_DIR}"
|
||||
CACHE PATH "Location of FluidSynth library directory")
|
||||
Finds the FluidSynth library.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module provides the following imported targets, if found:
|
||||
|
||||
``FluidSynth::libfluidsynth``
|
||||
The FluidSynth library
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
``FluidSynth_FOUND``
|
||||
True if the system has the FluidSynth library.
|
||||
``FluidSynth_INCLUDE_DIRS``
|
||||
Include directories needed to use FluidSynth.
|
||||
``FluidSynth_LIBRARIES``
|
||||
Libraries needed to link to FluidSynth.
|
||||
|
||||
Cache Variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The following cache variables may also be set:
|
||||
|
||||
``FluidSynth_INCLUDE_DIR``
|
||||
The directory containing ``FluidSynth.h``.
|
||||
``FluidSynth_DLL``
|
||||
The path to the FluidSynth Windows runtime.
|
||||
``FluidSynth_LIBRARY``
|
||||
The path to the FluidSynth library.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_FluidSynth QUIET fluidsynth>=${FluidSynth_FIND_VERSION})
|
||||
pkg_check_modules(PC_FLUIDSYNTH QUIET fluidsynth)
|
||||
|
||||
find_library(FluidSynth_LIBRARIES
|
||||
NAMES fluidsynth
|
||||
HINTS
|
||||
"${FluidSynth_DIR}/lib"
|
||||
${PC_FluidSynth_LIBDIR}
|
||||
)
|
||||
|
||||
find_path(FluidSynth_INCLUDE_DIRS
|
||||
find_path(
|
||||
FluidSynth_INCLUDE_DIR
|
||||
NAMES fluidsynth.h
|
||||
HINTS
|
||||
"${FluidSynth_DIR}/include"
|
||||
${PC_FluidSynth_INCLUDEDIR}
|
||||
HINTS "${PC_FLUIDSYNTH_INCLUDEDIR}"
|
||||
)
|
||||
|
||||
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()
|
||||
find_file(
|
||||
FluidSynth_DLL
|
||||
NAMES fluidsynth.dll libfluidsynth.dll libfluidsynth-3.dll
|
||||
PATH_SUFFIXES bin
|
||||
HINTS "${PC_FLUIDSYNTH_PREFIX}"
|
||||
)
|
||||
|
||||
find_library(
|
||||
FluidSynth_LIBRARY
|
||||
NAMES fluidsynth libfluidsynth
|
||||
HINTS "${PC_FLUIDSYNTH_LIBDIR}"
|
||||
)
|
||||
|
||||
if(FluidSynth_DLL OR FluidSynth_LIBRARY MATCHES ".so|.dylib")
|
||||
set(_fluidsynth_library_type SHARED)
|
||||
else()
|
||||
set(_fluidsynth_library_type STATIC)
|
||||
endif()
|
||||
|
||||
get_flags_from_pkg_config("${_fluidsynth_library_type}" "PC_FLUIDSYNTH" "_fluidsynth")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(FluidSynth
|
||||
FOUND_VAR FluidSynth_FOUND
|
||||
REQUIRED_VARS FluidSynth_LIBRARIES FluidSynth_INCLUDE_DIRS
|
||||
VERSION_VAR FluidSynth_VERSION
|
||||
)
|
||||
find_package_handle_standard_args(
|
||||
FluidSynth
|
||||
REQUIRED_VARS "FluidSynth_LIBRARY" "FluidSynth_INCLUDE_DIR")
|
||||
|
||||
if(FluidSynth_FOUND AND NOT TARGET FluidSynth::libfluidsynth)
|
||||
add_library(FluidSynth::libfluidsynth UNKNOWN IMPORTED)
|
||||
set_target_properties(FluidSynth::libfluidsynth PROPERTIES
|
||||
IMPORTED_LOCATION "${FluidSynth_LIBRARIES}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${FluidSynth_INCLUDE_DIRS}"
|
||||
)
|
||||
if(WIN32 AND FluidSynth_DIR)
|
||||
# On Windows, we need to figure out the location of our library files
|
||||
# so we can copy and package them.
|
||||
set(FluidSynth_DLL_DIR "${FluidSynth_DIR}/bin" CACHE INTERNAL "")
|
||||
if(FluidSynth_FOUND)
|
||||
if(NOT TARGET FluidSynth::libfluidsynth)
|
||||
add_library(FluidSynth::libfluidsynth ${_fluidsynth_library_type} IMPORTED)
|
||||
set_target_properties(
|
||||
FluidSynth::libfluidsynth
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FluidSynth_INCLUDE_DIR}"
|
||||
INTERFACE_COMPILE_OPTIONS "${_fluidsynth_compile_options}"
|
||||
INTERFACE_LINK_LIBRARIES "${_fluidsynth_link_libraries}"
|
||||
INTERFACE_LINK_DIRECTORIES "${_fluidsynth_link_directories}"
|
||||
INTERFACE_LINK_OPTIONS "${_fluidsynth_link_options}"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(FluidSynth_DLL)
|
||||
set_target_properties(
|
||||
FluidSynth::libfluidsynth
|
||||
PROPERTIES IMPORTED_LOCATION "${FluidSynth_DLL}"
|
||||
IMPORTED_IMPLIB "${FluidSynth_LIBRARY}"
|
||||
)
|
||||
else()
|
||||
set_target_properties(
|
||||
FluidSynth::libfluidsynth
|
||||
PROPERTIES IMPORTED_LOCATION "${FluidSynth_LIBRARY}"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(FluidSynth_LIBRARIES FluidSynth::libfluidsynth)
|
||||
set(FluidSynth_INCLUDE_DIRS "${FluidSynth_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
FluidSynth_INCLUDE_DIR
|
||||
FluidSynth_DLL
|
||||
FluidSynth_LIBRARY
|
||||
)
|
||||
|
50
cmake/PkgConfigHelper.cmake
Normal file
50
cmake/PkgConfigHelper.cmake
Normal file
@ -0,0 +1,50 @@
|
||||
# Helper for Find modules
|
||||
|
||||
function(get_flags_from_pkg_config _library_type _pc_prefix _out_prefix)
|
||||
if(NOT ${_pc_prefix}_FOUND)
|
||||
set(${_out_prefix}_compile_options
|
||||
""
|
||||
PARENT_SCOPE)
|
||||
set(${_out_prefix}_link_libraries
|
||||
""
|
||||
PARENT_SCOPE)
|
||||
set(${_out_prefix}_link_options
|
||||
""
|
||||
PARENT_SCOPE)
|
||||
set(${_out_prefix}_link_directories
|
||||
""
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if("${_library_type}" STREQUAL "STATIC")
|
||||
set(_cflags ${_pc_prefix}_STATIC_CFLAGS_OTHER)
|
||||
set(_link_libraries ${_pc_prefix}_STATIC_LIBRARIES)
|
||||
set(_link_options ${_pc_prefix}_STATIC_LDFLAGS_OTHER)
|
||||
set(_library_dirs ${_pc_prefix}_STATIC_LIBRARY_DIRS)
|
||||
else()
|
||||
set(_cflags ${_pc_prefix}_CFLAGS_OTHER)
|
||||
set(_link_libraries ${_pc_prefix}_LIBRARIES)
|
||||
set(_link_options ${_pc_prefix}_LDFLAGS_OTHER)
|
||||
set(_library_dirs ${_pc_prefix}_LIBRARY_DIRS)
|
||||
endif()
|
||||
|
||||
# The *_LIBRARIES lists always start with the library itself
|
||||
list(REMOVE_AT "${_link_libraries}" 0)
|
||||
|
||||
# Work around CMake's flag deduplication when pc files use `-framework A` instead of `-Wl,-framework,A`
|
||||
string(REPLACE "-framework;" "-Wl,-framework," "_filtered_link_options" "${${_link_options}}")
|
||||
|
||||
set(${_out_prefix}_compile_options
|
||||
"${${_cflags}}"
|
||||
PARENT_SCOPE)
|
||||
set(${_out_prefix}_link_libraries
|
||||
"${${_link_libraries}}"
|
||||
PARENT_SCOPE)
|
||||
set(${_out_prefix}_link_options
|
||||
"${_filtered_link_options}"
|
||||
PARENT_SCOPE)
|
||||
set(${_out_prefix}_link_directories
|
||||
"${${_library_dirs}}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
@ -201,7 +201,7 @@ endif()
|
||||
|
||||
target_link_libraries(woof PRIVATE ${WOOF_LIBRARIES}
|
||||
SDL2::SDL2
|
||||
$<IF:$<TARGET_EXISTS:SDL2_net::SDL2_net>,SDL2_net::SDL2_net,SDL2_net::SDL2_net-static>
|
||||
SDL2_net::SDL2_net
|
||||
OpenAL::OpenAL
|
||||
SndFile::sndfile
|
||||
opl
|
||||
@ -249,7 +249,7 @@ target_include_directories(woof-setup PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
|
||||
target_link_libraries(woof-setup PRIVATE
|
||||
$<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
|
||||
SDL2::SDL2
|
||||
$<IF:$<TARGET_EXISTS:SDL2_net::SDL2_net>,SDL2_net::SDL2_net,SDL2_net::SDL2_net-static>
|
||||
SDL2_net::SDL2_net
|
||||
textscreen
|
||||
setup)
|
||||
|
||||
|
@ -5,7 +5,10 @@
|
||||
"sdl2-net",
|
||||
"openal-soft",
|
||||
"libsndfile",
|
||||
"fluidsynth",
|
||||
{
|
||||
"name": "fluidsynth",
|
||||
"default-features": false
|
||||
},
|
||||
{
|
||||
"name": "libxmp",
|
||||
"default-features": false
|
||||
|
Loading…
x
Reference in New Issue
Block a user