[vlc-commits] [Git][videolan/vlc][master] contrib: gme: use CMAKE_CXX_IMPLICIT_LINK_LIBRARIES to get the C++ runtime
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Tue Sep 6 13:27:21 UTC 2022
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
740d93a6 by Steve Lhomme at 2022-09-06T12:34:17+00:00
contrib: gme: use CMAKE_CXX_IMPLICIT_LINK_LIBRARIES to get the C++ runtime
And since we need to patch the pkg-config, add libm from there as well.
- - - - -
6 changed files:
- + contrib/src/gme/0001-Export-the-proper-C-runtime-library.patch
- + contrib/src/gme/0002-link-with-libm-and-set-it-in-pkg-config-when-buildin.patch
- + contrib/src/gme/0003-fix-android-toolchain-broken-CMAKE_CXX_IMPLICIT_LINK.patch
- − contrib/src/gme/add-libm.patch
- − contrib/src/gme/mac-use-c-stdlib.patch
- contrib/src/gme/rules.mak
Changes:
=====================================
contrib/src/gme/0001-Export-the-proper-C-runtime-library.patch
=====================================
@@ -0,0 +1,53 @@
+From a025cafddfa3c9a41625c08c384e90db88507bb5 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 5 Sep 2022 13:34:41 +0200
+Subject: [PATCH 1/3] Export the proper C++ runtime library
+
+With gcc it's libstdc++, with clang it's libc++. So let CMake give it to use
+and use all the libraries it needs, except some noise from clang toolchains.
+---
+ gme/CMakeLists.txt | 17 +++++++++++++++++
+ gme/libgme.pc.in | 2 +-
+ 2 files changed, 18 insertions(+), 1 deletion(-)
+
+diff --git a/gme/CMakeLists.txt b/gme/CMakeLists.txt
+index b1b2bf0..51adade 100644
+--- a/gme/CMakeLists.txt
++++ b/gme/CMakeLists.txt
+@@ -193,6 +193,23 @@ set_target_properties(gme
+ PROPERTIES VERSION ${GME_VERSION}
+ SOVERSION 0)
+
++foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES})
++ if(IS_ABSOLUTE ${LIB} AND EXISTS ${LIB})
++ list(APPEND IMPLICITS_LIST "${LIB}")
++ else()
++ list(APPEND IMPLICITS_LIST "-l${LIB}")
++ endif()
++endforeach()
++if(IMPLICITS_LIST)
++ # blacklist of libraries that should not be in Libs.private
++ list(REMOVE_ITEM IMPLICITS_LIST "-lmingwex"
++ "-lmingw32" "-lmoldname" "-lmsvcrt" "-ladvapi32" "-lshell32"
++ "-luser32" "-lkernel32")
++ string(REPLACE ";" " " PKG_CONFIG_CXXRT "${IMPLICITS_LIST}")
++else()
++ set(PKG_CONFIG_CXXRT "")
++endif(IMPLICITS_LIST)
++
+ # macOS framework build
+ if(BUILD_FRAMEWORK)
+ set_target_properties(gme
+diff --git a/gme/libgme.pc.in b/gme/libgme.pc.in
+index f057ce1..a0e8986 100644
+--- a/gme/libgme.pc.in
++++ b/gme/libgme.pc.in
+@@ -13,4 +13,4 @@ URL: https://bitbucket.org/mpyne/game-music-emu/wiki/Home
+ Version: @GME_VERSION@
+ Cflags: -I${includedir}
+ Libs: -L${libdir} -lgme
+-Libs.private: -lstdc++ @PKG_CONFIG_ZLIB@
++Libs.private: @PKG_CONFIG_CXXRT@ @PKG_CONFIG_ZLIB@
+--
+2.27.0.windows.1
+
=====================================
contrib/src/gme/0002-link-with-libm-and-set-it-in-pkg-config-when-buildin.patch
=====================================
@@ -0,0 +1,41 @@
+From 327bda2f8517f9c35b5a734556a579c1781338fc Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 5 Sep 2022 13:48:27 +0200
+Subject: [PATCH 2/3] link with libm and set it in pkg-config when building on
+ UNIX
+
+It's exported with PKG_CONFIG_CXXRT
+---
+ gme/CMakeLists.txt | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/gme/CMakeLists.txt b/gme/CMakeLists.txt
+index 51adade..da23ea8 100644
+--- a/gme/CMakeLists.txt
++++ b/gme/CMakeLists.txt
+@@ -210,6 +210,22 @@ else()
+ set(PKG_CONFIG_CXXRT "")
+ endif(IMPLICITS_LIST)
+
++set(TEST_MATH_LINK "#include <math.h>\n
++int main(int argc, char** argv) { return (int)pow(argc, 2.5); }")
++
++check_cxx_source_compiles("${TEST_MATH_LINK}" HAVE_MATH_LIBRARY)
++if(NOT HAVE_MATH_LIBRARY)
++ set(CMAKE_REQUIRED_LIBRARIES "-lm")
++ check_cxx_source_compiles("${TEST_MATH_LINK}" NEEDS_MATH_LIBRARY)
++ unset(CMAKE_REQUIRED_LIBRARIES)
++ if(NEEDS_MATH_LIBRARY)
++ message(STATUS "Adding -lm flag.")
++ target_link_libraries(gme PRIVATE m)
++ set(PKG_CONFIG_CXXRT "${PKG_CONFIG_CXXRT} -lm")
++ endif(NEEDS_MATH_LIBRARY)
++endif()
++
++
+ # macOS framework build
+ if(BUILD_FRAMEWORK)
+ set_target_properties(gme
+--
+2.27.0.windows.1
+
=====================================
contrib/src/gme/0003-fix-android-toolchain-broken-CMAKE_CXX_IMPLICIT_LINK.patch
=====================================
@@ -0,0 +1,31 @@
+From 5fb77ca7127ab4343281920d79a87a899c6bc6bb Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Tue, 6 Sep 2022 11:56:30 +0200
+Subject: [PATCH 3/3] fix android toolchain broken
+ CMAKE_CXX_IMPLICIT_LINK_LIBRARIES
+
+CMake 3.17.0 and Android NDK 25 the CMAKE_CXX_IMPLICIT_LINK_LIBRARIES is
+c++;m;-l:libunwind.a;dl;c;-l:libunwind.a;dl
+
+When it should be
+c++;m;unwind;dl;c;unwind;dl
+---
+ gme/CMakeLists.txt | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/gme/CMakeLists.txt b/gme/CMakeLists.txt
+index da23ea8..77738c4 100644
+--- a/gme/CMakeLists.txt
++++ b/gme/CMakeLists.txt
+@@ -196,6 +196,8 @@ set_target_properties(gme
+ foreach(LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES})
+ if(IS_ABSOLUTE ${LIB} AND EXISTS ${LIB})
+ list(APPEND IMPLICITS_LIST "${LIB}")
++ elseif(${LIB} MATCHES "-l:libunwind.a") # android toolchain
++ list(APPEND IMPLICITS_LIST "-lunwind")
+ else()
+ list(APPEND IMPLICITS_LIST "-l${LIB}")
+ endif()
+--
+2.27.0.windows.1
+
=====================================
contrib/src/gme/add-libm.patch deleted
=====================================
@@ -1,8 +0,0 @@
---- game-music-emu-0.6.3/gme/libgme.pc.in.old 2022-08-26 08:35:03.000000000 +0200
-+++ game-music-emu-0.6.3/gme/libgme.pc.in 2022-08-26 08:35:18.000000000 +0200
-@@ -13,4 +13,4 @@
- Version: @GME_VERSION@
- Cflags: -I${includedir}
- Libs: -L${libdir} -lgme
--Libs.private: -lstdc++ @PKG_CONFIG_ZLIB@
-+Libs.private: -lstdc++ -lm @PKG_CONFIG_ZLIB@
=====================================
contrib/src/gme/mac-use-c-stdlib.patch deleted
=====================================
@@ -1,8 +0,0 @@
---- game-music-emu/gme/libgme.pc.in.old 2022-08-25 21:46:36.000000000 +0200
-+++ game-music-emu/gme/libgme.pc.in 2022-08-25 21:46:57.000000000 +0200
-@@ -13,4 +13,4 @@
- Version: @GME_VERSION@
- Cflags: -I${includedir}
- Libs: -L${libdir} -lgme
--Libs.private: -lstdc++ -lm @PKG_CONFIG_ZLIB@
-+Libs.private: -lc++ -lm @PKG_CONFIG_ZLIB@
=====================================
contrib/src/gme/rules.mak
=====================================
@@ -15,10 +15,9 @@ DEPS_gme = zlib $(DEPS_zlib)
game-music-emu: game-music-emu-$(GME_VERSION).tar.xz .sum-gme
$(UNPACK)
$(APPLY) $(SRC)/gme/skip-underrun.patch
- $(APPLY) $(SRC)/gme/add-libm.patch
-ifdef HAVE_MACOSX
- $(APPLY) $(SRC)/gme/mac-use-c-stdlib.patch
-endif
+ $(APPLY) $(SRC)/gme/0001-Export-the-proper-C-runtime-library.patch
+ $(APPLY) $(SRC)/gme/0002-link-with-libm-and-set-it-in-pkg-config-when-buildin.patch
+ $(APPLY) $(SRC)/gme/0003-fix-android-toolchain-broken-CMAKE_CXX_IMPLICIT_LINK.patch
$(call pkg_static,"gme/libgme.pc.in")
$(MOVE)
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/740d93a609150ec938610ab250dbe8f1e8979c9a
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/740d93a609150ec938610ab250dbe8f1e8979c9a
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list