Skip to content

Commit

Permalink
vcpkg: fix sndfile FluidSynth option
Browse files Browse the repository at this point in the history
* Ignore `C:/Strawberry/perl` PATH in Windows-2022 image. Turns out it contains a broken pkg-config.

* Remove PkgConfigHelper.

* Restore "*.sf3" soundfonts loading.
  • Loading branch information
rfomin committed May 2, 2023
1 parent e334052 commit 8c33950
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 140 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/win_msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ jobs:
-DCMAKE_BUILD_TYPE=Release -DENABLE_WERROR=ON -DENABLE_LTO=ON `
-DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" `
-DVCPKG_TARGET_TRIPLET="${{ matrix.arch }}-windows-static-release" `
-DVCPKG_OVERLAY_TRIPLETS="cmake/triplets"
-DVCPKG_OVERLAY_TRIPLETS="cmake/triplets" `
-DCMAKE_IGNORE_PATH="C:/Strawberry/perl/bin;C:/Strawberry/c/lib"
- name: Build
run: cmake --build build
Expand Down
8 changes: 1 addition & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,9 @@ check_include_file("dirent.h" HAVE_DIRENT_H)
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)
Expand All @@ -77,7 +71,7 @@ if(SndFile_VERSION VERSION_GREATER_EQUAL "1.1.0")
set(HAVE_SNDFILE_MPEG TRUE)
endif()

find_package(FluidSynth 2.2.0)
find_package(FluidSynth)
find_package(libxmp)

if(FluidSynth_FOUND)
Expand Down
49 changes: 5 additions & 44 deletions cmake/FindFluidSynth.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ 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.
Expand All @@ -47,64 +45,27 @@ find_path(
HINTS "${PC_FLUIDSYNTH_INCLUDEDIR}"
)

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
REQUIRED_VARS "FluidSynth_LIBRARY" "FluidSynth_INCLUDE_DIR")
REQUIRED_VARS "FluidSynth_LIBRARY" "FluidSynth_INCLUDE_DIR"
VERSION_VAR "FluidSynth_VERSION")

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()
add_library(FluidSynth::libfluidsynth UNKNOWN IMPORTED)
set_target_properties(
FluidSynth::libfluidsynth
PROPERTIES IMPORTED_LOCATION "${FluidSynth_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FluidSynth_INCLUDE_DIR}"
)
endif()

set(FluidSynth_LIBRARIES FluidSynth::libfluidsynth)
set(FluidSynth_INCLUDE_DIRS "${FluidSynth_INCLUDE_DIR}")
endif()

mark_as_advanced(
FluidSynth_INCLUDE_DIR
FluidSynth_DLL
FluidSynth_LIBRARY
)
mark_as_advanced(FluidSynth_INCLUDE_DIR FluidSynth_LIBRARY)
40 changes: 4 additions & 36 deletions cmake/FindSndFile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,19 @@
find_package(PkgConfig QUIET)
pkg_check_modules(PC_SndFile QUIET sndfile)

set(SndFile_VERSION ${PC_SndFile_VERSION})

find_path(SndFile_INCLUDE_DIR sndfile.h
HINTS
${PC_SndFile_INCLUDEDIR}
${PC_SndFile_INCLUDE_DIRS}
${SNDFILE_DIR})

find_file(SndFile_DLL
NAMES sndfile.dll libsndfile.dll libsndfile-1.dll
PATH_SUFFIXES bin
HINTS ${PC_SndFile_PREFIX})

find_library(SndFile_LIBRARY
NAMES sndfile libsndfile
HINTS
${PC_SndFile_LIBDIR}
${PC_SndFile_LIBRARY_DIRS}
${SNDFILE_DIR})

if(SndFile_DLL OR SndFile_LIBRARY MATCHES ".so|.dylib")
set(_sndfile_library_type SHARED)
else()
set(_sndfile_library_type STATIC)
endif()

get_flags_from_pkg_config("${_sndfile_library_type}" "PC_SndFile" "_sndfile")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SndFile
REQUIRED_VARS
Expand All @@ -47,29 +32,12 @@ find_package_handle_standard_args(SndFile

if(SndFile_FOUND)
if(NOT TARGET SndFile::sndfile)
add_library(SndFile::sndfile ${_sndfile_library_type} IMPORTED)
add_library(SndFile::sndfile UNKNOWN IMPORTED)
set_target_properties(SndFile::sndfile
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SndFile_INCLUDE_DIR}"
INTERFACE_COMPILE_OPTIONS "${_sndfile_compile_options}"
INTERFACE_LINK_LIBRARIES "${_sndfile_link_libraries}"
INTERFACE_LINK_DIRECTORIES "${_sndfile_link_directories}"
INTERFACE_LINK_OPTIONS "${_sndfile_link_options}")
IMPORTED_LOCATION "${SndFile_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SndFile_INCLUDE_DIR}")
endif()

if(SndFile_DLL)
set_target_properties(SndFile::sndfile
PROPERTIES
IMPORTED_LOCATION "${SndFile_DLL}"
IMPORTED_IMPLIB "${SndFile_LIBRARY}")
else()
set_target_properties(SndFile::sndfile
PROPERTIES
IMPORTED_LOCATION "${SndFile_LIBRARY}")
endif()

set(SndFile_LIBRARIES SndFile::sndfile)
set(SndFile_INCLUDE_DIRS "${SndFile_INCLUDE_DIR}")
endif()

mark_as_advanced(SndFile_LIBRARY SndFile_INCLUDE_DIR SndFile_DLL)
mark_as_advanced(SndFile_LIBRARY SndFile_INCLUDE_DIR)
50 changes: 0 additions & 50 deletions cmake/PkgConfigHelper.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion src/i_flmusic.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static void AddSoundFont(const char *path)
static void ScanDir(const char *dir)
{
glob_t *glob = I_StartMultiGlob(dir, GLOB_FLAG_NOCASE|GLOB_FLAG_SORTED,
"*.sf2", NULL);
"*.sf2", "*.sf3", NULL);
while(1)
{
const char *filename = I_NextGlob(glob);
Expand Down
3 changes: 2 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"libsndfile",
{
"name": "fluidsynth",
"default-features": false
"default-features": false,
"features": ["sndfile"]
},
{
"name": "libxmp",
Expand Down

2 comments on commit 8c33950

@rfomin
Copy link
Collaborator Author

@rfomin rfomin commented on 8c33950 May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiangreffrath The installation of vcpkg in the windows-2022 image has been broken all this time and they refuse to fix it: actions/runner-images#5459. Disgusting!

Anyway, all known issues with static builds have now been fixed.

@fabiangreffrath
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that's really aweful. Thanks for fixing it!

Please sign in to comment.