[vlc-commits] [Git][videolan/vlc][master] contrib: zlib: build with CMake

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Sep 26 07:56:30 UTC 2022



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
c3af0218 by Steve Lhomme at 2022-09-26T07:38:16+02:00
contrib: zlib: build with CMake

- - - - -


3 changed files:

- + contrib/src/zlib/0001-Fix-mingw-static-library-name-on-mingw.patch
- − contrib/src/zlib/no-shared.patch
- contrib/src/zlib/rules.mak


Changes:

=====================================
contrib/src/zlib/0001-Fix-mingw-static-library-name-on-mingw.patch
=====================================
@@ -0,0 +1,30 @@
+From 7ee28d63afbfd9d87bf8976cfe8f84ca8bbe49a2 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Fri, 9 Sep 2022 10:19:56 +0200
+Subject: [PATCH] Fix mingw static library name on mingw
+
+mingw builds code in a UNIX like environment but CMake doesn't set UNIX for it.
+---
+ CMakeLists.txt | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index e6fbb37..3fa3046 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -199,10 +199,10 @@ if(NOT CYGWIN)
+     set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
+ endif()
+
+-if(UNIX)
++if(UNIX OR MINGW)
+     # On unix-like platforms the library is almost always called libz
+    set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
+-   if(NOT APPLE)
++   if(NOT APPLE AND NOT MINGW)
+      set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
+    endif()
+ elseif(BUILD_SHARED_LIBS AND WIN32)
+--
+2.37.3.windows.1
+


=====================================
contrib/src/zlib/no-shared.patch deleted
=====================================
@@ -1,12 +0,0 @@
---- zlib/win32/Makefile.gcc.orig	2016-08-30 16:03:24.458949860 +0000
-+++ zlib/win32/Makefile.gcc	2016-08-30 16:03:29.598983275 +0000
-@@ -90,7 +90,8 @@
- $(STATICLIB): $(OBJS) $(OBJA)
- 	$(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA)
- 
--$(IMPLIB): $(SHAREDLIB)
-+$(IMPLIB):
-+	touch $@
- 
- $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o
- 	$(CC) -shared -Wl,--out-implib,$(IMPLIB) $(LDFLAGS) \


=====================================
contrib/src/zlib/rules.mak
=====================================
@@ -7,12 +7,6 @@ ifeq ($(call need_pkg,"zlib"),)
 PKGS_FOUND += zlib
 endif
 
-ifeq ($(shell uname),Darwin) # zlib tries to use libtool on Darwin
-ifdef HAVE_CROSS_COMPILE
-ZLIB_CONFIG_VARS=CHOST=$(HOST)
-endif
-endif
-
 $(TARBALLS)/zlib-$(ZLIB_VERSION).tar.gz:
 	$(call download_pkg,$(ZLIB_URL),zlib)
 
@@ -20,14 +14,24 @@ $(TARBALLS)/zlib-$(ZLIB_VERSION).tar.gz:
 
 zlib: zlib-$(ZLIB_VERSION).tar.gz .sum-zlib
 	$(UNPACK)
-	$(APPLY) $(SRC)/zlib/no-shared.patch
+	$(APPLY) $(SRC)/zlib/0001-Fix-mingw-static-library-name-on-mingw.patch
+	# disable the installation of the dynamic library since there's no option
+	cd $(UNPACK_DIR) && sed -e 's,install(TARGETS zlib zlibstatic,install(TARGETS zlibstatic,' -i.orig CMakeLists.txt
 	$(MOVE)
 
-.zlib: zlib
-ifdef HAVE_WIN32
-	$(HOSTVARS) $(MAKE) -C $< -fwin32/Makefile.gcc install $(HOSTVARS) $(ZLIB_CONFIG_VARS) LD="$(CC)" prefix="$(PREFIX)" INCLUDE_PATH="$(PREFIX)/include" LIBRARY_PATH="$(PREFIX)/lib" BINARY_PATH="$(PREFIX)/bin"
-else
-	cd $< && $(HOSTVARS_PIC) $(ZLIB_CONFIG_VARS) ./configure --prefix=$(PREFIX) --static
-	$(MAKE) -C $< install
-endif
+ZLIB_CONF = -DINSTALL_PKGCONFIG_DIR:STRING=$(PREFIX)/lib/pkgconfig
+
+# ASM is disabled as the necessary source files are not in the tarball nor the git
+# ifeq ($(ARCH),i386)
+# ZLIB_CONF += -DASM686=ON
+# endif
+# ifeq ($(ARCH),x86_64)
+# ZLIB_CONF += -DAMD64=ON
+# endif
+
+.zlib: zlib toolchain.cmake
+	$(CMAKECLEAN)
+	$(HOSTVARS) $(CMAKE) $(ZLIB_CONF)
+	+$(CMAKEBUILD)
+	+$(CMAKEBUILD) --target install
 	touch $@



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c3af02188c623692d33a703020f65ecf3d18f39e

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c3af02188c623692d33a703020f65ecf3d18f39e
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