]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
cmake: respect custom `RC` flags and delete `GCC_WINDRES`
authorViktor Szakats <commit@vsz.me>
Sun, 17 Jul 2022 19:33:01 +0000 (19:33 +0000)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 17 Aug 2022 12:42:34 +0000 (14:42 +0200)
Before this patch, `zlib.rc` was compiled using a manual command [1] when
using the MinGW (and MSYS/Cygwin) toolchains. This method ignores
`CMAKE_RC_FLAGS` and offers no other way to pass a custom flag, breaking
the build in cases where a custom `windres` option is required. E.g.
`--target=` or `-I` on some platforms and configuration, in particular
with `llvm-windres`.

This patch deletes the special case for these toolchains and lets CMake
compile the `.rc` file the default way used for all Windows targets.

I'm not entirely sure why this special case was added back in 2011. The
need to pass `-DGCC_WINDRES` is my suspect. We can resolve this much
simpler by adding this line for the targets that require it:
   set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DGCC_WINDRES")

But, the `.rc` line protected by `GCC_WINDRES`, these days work just fine
with `windres`. Moreover, that protected line are oboslete flags from the
16-bit era, which for a long time have no effect, as documented here:
<https://docs.microsoft.com/windows/win32/menurc/common-resource-attributes>

So, this patch deletes `GCC_WINDRES` from the project entirely.

[1] dc5a43e

CMakeLists.txt
configure
win32/zlib-ng1.rc
win32/zlib1.rc

index d8f45b743d308d110817012609af522723d6fe80..fafedb9ce203261f0239bd31e96d0a4dd4f4d048 100644 (file)
@@ -997,26 +997,7 @@ if(WITH_GZFILEOP)
 endif()
 
 if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
-    if(NOT MINGW AND NOT MSYS AND NOT CYGWIN)
-        # If present will override custom build rule below.
-        set(ZLIB_DLL_SRCS win32/zlib${SUFFIX}1.rc)
-    endif()
-
-    if(MINGW OR MSYS OR CYGWIN)
-        # This gets us DLL resource information when compiling on MinGW.
-        if(NOT CMAKE_RC_COMPILER)
-            set(CMAKE_RC_COMPILER windres.exe)
-        endif()
-
-        add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-            COMMAND ${CMAKE_RC_COMPILER}
-                -D GCC_WINDRES
-                -I ${CMAKE_CURRENT_SOURCE_DIR}
-                -I ${CMAKE_CURRENT_BINARY_DIR}
-                -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-                -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib${SUFFIX}1.rc)
-        set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
-    endif()
+    set(ZLIB_DLL_SRCS win32/zlib${SUFFIX}1.rc)
 endif()
 
 if(NOT DEFINED BUILD_SHARED_LIBS)
index f28f1dba2f1de4639b9e63a58cd897a5816b0498..4e73a22dcc672f9d62b0a8c14c0e2b47bfac1bab 100755 (executable)
--- a/configure
+++ b/configure
@@ -432,7 +432,6 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then
         LDSHAREDLIBC=""
         DEFFILE='win32/${LIBNAME2}.def'
         RC="${CROSS_PREFIX}windres"
-        RCFLAGS='--define GCC_WINDRES'
         RCOBJS='zlibrc.o'
         STRIP="${CROSS_PREFIX}strip"
         EXE='.exe' ;;
@@ -455,7 +454,6 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then
         LDSHAREDLIBC=""
         DEFFILE='win32/${LIBNAME2}.def'
         RC="${CROSS_PREFIX}windres"
-        RCFLAGS='--define GCC_WINDRES'
         RCOBJS='zlibrc.o'
         STRIP="${CROSS_PREFIX}strip"
         EXE='.exe' ;;
@@ -475,7 +473,6 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then
         LDSHAREDLIBC=""
         DEFFILE='win32/${LIBNAME2}.def'
         RC="${CROSS_PREFIX}windres"
-        RCFLAGS='--define GCC_WINDRES'
         if [ "$CC" == "mingw32-gcc" ]; then
           case $ARCH in
           i386 | i486 | i586 | i686) RCFLAGS="${RCFLAGS} -F pe-i386";;
index f524131462531664d9750ede67bcabaf291a8c0c..327f17fd8b41a560fe7167d26754e0156d83f989 100644 (file)
@@ -1,11 +1,7 @@
 #include <winver.h>
 #include "zlib-ng.h"
 
-#ifdef GCC_WINDRES
 VS_VERSION_INFO                VERSIONINFO
-#else
-VS_VERSION_INFO                VERSIONINFO     MOVEABLE IMPURE LOADONCALL DISCARDABLE
-#endif
   FILEVERSION          ZLIBNG_VER_MAJOR,ZLIBNG_VER_MINOR,ZLIBNG_VER_REVISION,0
   PRODUCTVERSION       ZLIBNG_VER_MAJOR,ZLIBNG_VER_MINOR,ZLIBNG_VER_REVISION,0
   FILEFLAGSMASK                VS_FFI_FILEFLAGSMASK
index ee0b287953ffb213c8a27569c856f374c3f20b71..82e5934c2bec58f7e4ac935823401b1db70a52d8 100644 (file)
@@ -1,11 +1,7 @@
 #include <winver.h>
 #include "zlib.h"
 
-#ifdef GCC_WINDRES
 VS_VERSION_INFO                VERSIONINFO
-#else
-VS_VERSION_INFO                VERSIONINFO     MOVEABLE IMPURE LOADONCALL DISCARDABLE
-#endif
   FILEVERSION          ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0
   PRODUCTVERSION       ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0
   FILEFLAGSMASK                VS_FFI_FILEFLAGSMASK