summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViktor Szakats <commit@vsz.me>2022-07-17 19:33:01 +0000
committerHans Kristian Rosbach <hk-github@circlestorm.org>2023-03-17 21:27:56 +0100
commitc1d2326e7097b3ad2bc1890acb663d6d0bf88f1f (patch)
tree510573c889cdd221dc215db13f951f8a40162782
parent08e3044fdcb66ab6da423a0764cae96db72e3d77 (diff)
cmake: respect custom `RC` flags and delete `GCC_WINDRES`
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
-rw-r--r--CMakeLists.txt22
-rwxr-xr-xconfigure3
-rw-r--r--win32/zlib-ng1.rc4
-rw-r--r--win32/zlib1.rc4
4 files changed, 2 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bf7944a..f8c1f13 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -965,26 +965,8 @@ set(ZLIB_GZFILE_SRCS
gzwrite.c
)
-if(NOT MINGW AND NOT MSYS AND NOT CYGWIN)
- set(ZLIB_DLL_SRCS
- win32/zlib${SUFFIX}1.rc # If present will override custom build rule below.
- )
-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)
+if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
+ set(ZLIB_DLL_SRCS win32/zlib${SUFFIX}1.rc)
endif()
set(ZLIB_ALL_SRCS ${ZLIB_SRCS} ${ZLIB_ARCH_HDRS} ${ZLIB_ARCH_SRCS} ${ZLIB_DLL_SRCS}
diff --git a/configure b/configure
index a7dfc5b..83b3ead 100755
--- a/configure
+++ b/configure
@@ -402,7 +402,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' ;;
@@ -425,7 +424,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' ;;
@@ -445,7 +443,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";;
diff --git a/win32/zlib-ng1.rc b/win32/zlib-ng1.rc
index b539069..128b56d 100644
--- a/win32/zlib-ng1.rc
+++ b/win32/zlib-ng1.rc
@@ -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
diff --git a/win32/zlib1.rc b/win32/zlib1.rc
index 11be5f4..39bdcc0 100644
--- a/win32/zlib1.rc
+++ b/win32/zlib1.rc
@@ -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