Skip to content

Commit

Permalink
[sdl2-mixer] Fix FLAC symbol export when static linking, add nativemi…
Browse files Browse the repository at this point in the history
…di default feature (#12374)

* [sdl2-mixer] Fix FLAC symbol export when static linking

Fix regression introduced by #11152

* [sdl2-mixer] Add nativemidi default feature

Closes #10318

* [libsndfile] Revert to port version 8 as version 10

* [libflac] Use BUILD_SHARED_LIBS to properly export FLAC__NO_DLL via CMake

* [libflac] Force FLAC__NO_DLL in installed headers in static triplets

* [libflac] Modify headers on installation
  • Loading branch information
kevinlul authored Jul 31, 2020
1 parent 4b0f9cb commit 62d4320
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 9 deletions.
3 changes: 2 additions & 1 deletion ports/libflac/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Source: libflac
Version: 1.3.3-1
Version: 1.3.3
Port-Version: 2
Homepage: https://xiph.org/flac/
Description: Library for manipulating FLAC files
Build-Depends: libogg
29 changes: 28 additions & 1 deletion ports/libflac/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ vcpkg_from_github(
"${CMAKE_CURRENT_LIST_DIR}/uwp-createfile2.patch"
)

if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
set(BUILD_SHARED_LIBS ON)
else()
set(BUILD_SHARED_LIBS OFF)
endif()

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DBUILD_PROGRAMS=OFF
-DBUILD_EXAMPLES=OFF
-DBUILD_DOCS=OFF
-DBUILD_TESTING=OFF)
-DBUILD_TESTING=OFF
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS})

vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(
Expand All @@ -28,6 +35,26 @@ vcpkg_copy_pdbs()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)

if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")

This comment has been minimized.

Copy link
@evpobr

evpobr Aug 19, 2020

Contributor

@kevinlul , why did you revert half of my PR instead of just adding -D__FLAC_NO_DLL to CMAKE_C_FLAGS here?

vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/FLAC/export.h
"#if defined(FLAC__NO_DLL)"
"#if 0"
)
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/FLAC++/export.h
"#if defined(FLAC__NO_DLL)"
"#if 0"
)
else()
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/FLAC/export.h
"#if defined(FLAC__NO_DLL)"
"#if 1"
)
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/FLAC++/export.h
"#if defined(FLAC__NO_DLL)"
"#if 1"
)
endif()

# This license (BSD) is relevant only for library - if someone would want to install
# FLAC cmd line tools as well additional license (GPL) should be included
file(COPY ${SOURCE_PATH}/COPYING.Xiph DESTINATION ${CURRENT_PACKAGES_DIR}/share/libflac)
Expand Down
3 changes: 2 additions & 1 deletion ports/libsndfile/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Source: libsndfile
Version: 1.0.29-9
Version: 1.0.29
Port-Version: 10
Description: Library to read, write and manipulate many soundfile types. Authored by Eric de Castro Lopo
Homepage: https://github.com/erikd/libsndfile
Default-Features: external-libs
Expand Down
4 changes: 0 additions & 4 deletions ports/libsndfile/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ option(BUILD_EXECUTABLES "Build sndfile tools and install to folder tools" OFF)

if("external-libs" IN_LIST FEATURES)
set(SNDFILE_WITHOUT_EXTERNAL_LIBS OFF)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(FLAC_EXPORT_DEFINITION "-DFLAC__NO_DLL")
endif()
else()
set(SNDFILE_WITHOUT_EXTERNAL_LIBS ON)
endif()
Expand All @@ -37,7 +34,6 @@ vcpkg_configure_cmake(
-DENABLE_STATIC_RUNTIME=${CRT_LIB_STATIC}
-DBUILD_STATIC_LIBS=${BUILD_STATIC}
-DDISABLE_EXTERNAL_LIBS=${SNDFILE_WITHOUT_EXTERNAL_LIBS}
-DCMAKE_C_FLAGS=${FLAC_EXPORT_DEFINITION}
OPTIONS_RELEASE
-DBUILD_PROGRAMS=${BUILD_EXECUTABLES}
OPTIONS_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion ports/sdl2-mixer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ add_library(SDL2_mixer
music_wav.c
version.rc)

if(WIN32 OR APPLE)
if((WIN32 OR APPLE) AND SDL_MIXER_ENABLE_NATIVEMIDI)
list(APPEND SDL_MIXER_DEFINES MUSIC_MID_NATIVE)
target_sources(SDL2_mixer PRIVATE music_nativemidi.c native_midi/native_midi_common.c)
target_link_libraries(SDL2_mixer ${SDL_MIXER_LIBRARIES})
Expand Down
7 changes: 6 additions & 1 deletion ports/sdl2-mixer/CONTROL
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
Source: sdl2-mixer
Version: 2.0.4-9
Version: 2.0.4
Port-Version: 10
Homepage: https://www.libsdl.org/projects/SDL_mixer
Description: Multi-channel audio mixer library for SDL.
Build-Depends: sdl2
Default-Features: nativemidi

Feature: dynamic-load
Description: Load plugins with dynamic call

Feature: nativemidi
Description: Support for MIDI audio format on Windows and macOS.

Feature: libflac
Description: Support for FLAC audio format.
Build-Depends: libflac
Expand Down
1 change: 1 addition & 0 deletions ports/sdl2-mixer/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
libmodplug SDL_MIXER_ENABLE_MOD
libvorbis SDL_MIXER_ENABLE_OGGVORBIS
opusfile SDL_MIXER_ENABLE_OPUS
nativemidi SDL_MIXER_ENABLE_NATIVEMIDI
)

vcpkg_configure_cmake(
Expand Down

0 comments on commit 62d4320

Please sign in to comment.