From 4af63c6f3ed667437b8fe0789a7fbc29936c9802 Mon Sep 17 00:00:00 2001 From: jim wang <122244446+jimwang118@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:33:24 +0000 Subject: [PATCH] [libopnmidi] Fix compilation errors under Linux (#38410) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix one of https://github.com/microsoft/vcpkg/issues/32398 issue. The following error occurs when installing `libopnmidi[core,pmdwin-emulator,gens-emulator]:x64-linux`. ``` /mnt/vcpkg/buildtrees/libopnmidi/src/v1.5.1-f0b18d03a5.clean/src/chips/pmdwin/op.h:36:8: error: unknown type name ‘inline’ 36 | static inline int16_t Limit16(int a) ``` The upstream author has fixed this issue in this [commit](https://github.com/Wohlstand/libOPNMIDI/commit/2324ff2e34451c2755ce0736a5072d2dd528c544). However, the upstream has not released a new version for the time being, so we fixed the issue through patches. - [X] Changes comply with the [maintainer guide](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md). - [ ] ~~SHA512s are updated for each updated download.~~ - [ ] ~~The "supports" clause reflects platforms that may be fixed by this new version.~~ - [ ] ~~Any fixed [CI baseline](https://github.com/microsoft/vcpkg/blob/master/scripts/ci.baseline.txt) entries are removed from that file.~~ - [ ] ~~Any patches that are no longer applied are deleted from the port's directory.~~ - [X] The version database is fixed by rerunning `./vcpkg x-add-version --all` and committing the result. - [X] Only one version is added to each modified port's versions file. Usage test pass with following triplets: ``` x64-windows x64-linux ``` --- ports/libopnmidi/fix-c++-standard.patch | 78 +++++++++++++++++++++++++ ports/libopnmidi/portfile.cmake | 1 + ports/libopnmidi/vcpkg.json | 2 +- versions/baseline.json | 2 +- versions/l-/libopnmidi.json | 5 ++ 5 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 ports/libopnmidi/fix-c++-standard.patch diff --git a/ports/libopnmidi/fix-c++-standard.patch b/ports/libopnmidi/fix-c++-standard.patch new file mode 100644 index 0000000000..965b6d5c33 --- /dev/null +++ b/ports/libopnmidi/fix-c++-standard.patch @@ -0,0 +1,78 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 20e167d..93885c3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,13 +1,35 @@ +-cmake_minimum_required (VERSION 3.2) ++cmake_minimum_required (VERSION 3.2...3.5) + project(libOPNMIDI VERSION 1.5.1 LANGUAGES C CXX) + + include(GNUInstallDirs) ++include(CheckCXXCompilerFlag) + + # Prefer C90 standard + set(CMAKE_C_STANDARD 90) + # Prefer C++98 standard + set(CMAKE_CXX_STANDARD 98) + ++if(MSVC) ++ check_cxx_compiler_flag("/std:c++14" COMPILER_SUPPORTS_CXX14) ++ if(COMPILER_SUPPORTS_CXX14) ++ set(FLAG_CPP14 "/std:c++14") ++ endif() ++ if(MSVC_VERSION LESS 1910) ++ unset(COMPILER_SUPPORTS_CXX14) # MSVC older than 2017 fails to build YMFM ++ endif() ++else() ++ check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORTS_CXX14) ++ if(COMPILER_SUPPORTS_CXX14) ++ set(FLAG_CPP14 "-std=c++14") ++ endif() ++endif() ++ ++if(COMPILER_SUPPORTS_CXX14) ++ message("== Your C++ compiler supports C++14, YMFM emulator will be ENABLED") ++else() ++ message("== Your C++ compiler does NOT supports C++14, YMFM emulator will be DISABLED") ++endif() ++ + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + endif() +@@ -59,13 +81,24 @@ if(NOT MSVC AND NOT MSDOS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVITA -DVITA=1 -fcompare-debug-second") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVITA -DVITA=1 -fcompare-debug-second") + endif() ++ if(NINTENDO_3DS OR NINTENDO_WII OR NINTENDO_WIIU OR NINTENDO_SWITCH) ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcompare-debug-second") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcompare-debug-second") ++ endif() + endif() + +-if(NOT CMAKE_BUILD_TYPE) +- set(CMAKE_BUILD_TYPE "Release") ++if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID STREQUAL "Clang") ++ if(NINTENDO_3DS OR NINTENDO_WII OR NINTENDO_WIIU OR NINTENDO_SWITCH) ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90") ++ else() ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89") ++ endif() ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98") + endif() + +-string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER) ++if(DEFINED CMAKE_BUILD_TYPE) ++ string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) ++endif() + if(CMAKE_BUILD_TYPE_LOWER EQUAL "release") + add_definitions(-DNDEBUG) + ENDIF() +@@ -88,7 +121,7 @@ function(set_legacy_standard destTarget) + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) + # Turn on warnings and legacy C/C++ standards to support more compilers + target_compile_options(${destTarget} PRIVATE +- $<$:-Wall -pedantic -std=c90> ++ $<$:-Wall -pedantic -std=gnu90> + $<$:-Wall -pedantic -std=gnu++98> + ) + endif() diff --git a/ports/libopnmidi/portfile.cmake b/ports/libopnmidi/portfile.cmake index 16e15fdc07..a312c7aae7 100644 --- a/ports/libopnmidi/portfile.cmake +++ b/ports/libopnmidi/portfile.cmake @@ -10,6 +10,7 @@ vcpkg_from_github( disable-wopn2hpp.patch fix-build-without-sequencer.patch fix-pmdwin-emulator-include.patch + fix-c++-standard.patch ) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS diff --git a/ports/libopnmidi/vcpkg.json b/ports/libopnmidi/vcpkg.json index 960d4aac26..1fd91a9ef7 100644 --- a/ports/libopnmidi/vcpkg.json +++ b/ports/libopnmidi/vcpkg.json @@ -1,7 +1,7 @@ { "name": "libopnmidi", "version": "1.5.1", - "port-version": 1, + "port-version": 2, "description": "libOPNMIDI is a free Software MIDI synthesizer library with OPN2 (YM2612) and OPNA (YM2608) emulation", "homepage": "https://github.com/Wohlstand/libOPNMIDI", "license": "LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR MIT", diff --git a/versions/baseline.json b/versions/baseline.json index 02584686d7..bef9ebf397 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4754,7 +4754,7 @@ }, "libopnmidi": { "baseline": "1.5.1", - "port-version": 1 + "port-version": 2 }, "libopusenc": { "baseline": "0.2.1", diff --git a/versions/l-/libopnmidi.json b/versions/l-/libopnmidi.json index 01b5525a48..c12412d938 100644 --- a/versions/l-/libopnmidi.json +++ b/versions/l-/libopnmidi.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "3b11c2e9b745c94c0ed9eb46044a21704dd2e94a", + "version": "1.5.1", + "port-version": 2 + }, { "git-tree": "2451642c9d81eff6810839a5174ca60053330780", "version": "1.5.1",