diff options
| author | Vollstrecker <werner@vollstreckernet.de> | 2024-12-01 16:56:09 +0100 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2025-01-31 19:59:10 -0800 |
| commit | 1af1bb6ce4b8e8d0b5b34985bafe7a8c3dd0e173 (patch) | |
| tree | 13b7d3b56e1fc809767dcb859da00b2d4bce6b07 | |
| parent | 899ef97c4a2ca0d9e27d3d91437f6da5e6eea218 (diff) | |
| download | zlib-1af1bb6ce4b8e8d0b5b34985bafe7a8c3dd0e173.tar.gz zlib-1af1bb6ce4b8e8d0b5b34985bafe7a8c3dd0e173.tar.bz2 zlib-1af1bb6ce4b8e8d0b5b34985bafe7a8c3dd0e173.zip | |
CMake: Let cmake handle zlib1.rc.
| -rw-r--r-- | CMakeLists.txt | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 74bc1a9..7edfc34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -82,31 +82,8 @@ set(ZLIB_SRCS | |||
| 82 | zutil.c | 82 | zutil.c |
| 83 | ) | 83 | ) |
| 84 | 84 | ||
| 85 | if(NOT MINGW) | 85 | set_source_files_properties(win32/zlib1.rc PROPERTIES |
| 86 | set(ZLIB_DLL_SRCS | 86 | COMPILE_FLAGS $<$<STREQUAL:${CMAKE_RC_OUTPUT_EXTENSION},.obj>:-DGCC_WINDRES>) |
| 87 | win32/zlib1.rc # If present will override custom build rule below. | ||
| 88 | ) | ||
| 89 | endif() | ||
| 90 | |||
| 91 | # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION | ||
| 92 | file(READ ${zlib_SOURCE_DIR}/zlib.h _zlib_h_contents) | ||
| 93 | string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" | ||
| 94 | "\\1" ZLIB_VERSION ${_zlib_h_contents}) | ||
| 95 | if(MINGW) | ||
| 96 | # This gets us DLL resource information when compiling on MinGW. | ||
| 97 | if(NOT CMAKE_RC_COMPILER) | ||
| 98 | set(CMAKE_RC_COMPILER windres.exe) | ||
| 99 | endif() | ||
| 100 | |||
| 101 | add_custom_command(OUTPUT ${zlib_BINARY_DIR}/zlib1rc.obj | ||
| 102 | COMMAND ${CMAKE_RC_COMPILER} | ||
| 103 | -D GCC_WINDRES | ||
| 104 | -I ${zlib_SOURCE_DIR} | ||
| 105 | -I ${zlib_BINARY_DIR} | ||
| 106 | -o ${zlib_BINARY_DIR}/zlib1rc.obj | ||
| 107 | -i ${zlib_SOURCE_DIR}/win32/zlib1.rc) | ||
| 108 | set(ZLIB_DLL_SRCS ${zlib_BINARY_DIR}/zlib1rc.obj) | ||
| 109 | endif(MINGW) | ||
| 110 | 87 | ||
| 111 | if(WIN32) | 88 | if(WIN32) |
| 112 | set (zlib_static_suffix "s") | 89 | set (zlib_static_suffix "s") |
| @@ -114,7 +91,12 @@ if(WIN32) | |||
| 114 | endif(WIN32) | 91 | endif(WIN32) |
| 115 | 92 | ||
| 116 | if(ZLIB_BUILD_SHARED) | 93 | if(ZLIB_BUILD_SHARED) |
| 117 | add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) | 94 | add_library(zlib SHARED |
| 95 | ${ZLIB_SRCS} | ||
| 96 | ${ZLIB_DLL_SRCS} | ||
| 97 | ${ZLIB_PUBLIC_HDRS} | ||
| 98 | ${ZLIB_PRIVATE_HDRS} | ||
| 99 | $<$<BOOL:${WIN32}>:win32/zlib1.rc>) | ||
| 118 | target_include_directories(zlib PUBLIC | 100 | target_include_directories(zlib PUBLIC |
| 119 | $<BUILD_INTERFACE:${zlib_BINARY_DIR}> | 101 | $<BUILD_INTERFACE:${zlib_BINARY_DIR}> |
| 120 | $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>) | 102 | $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>) |
| @@ -137,7 +119,10 @@ if(ZLIB_BUILD_SHARED) | |||
| 137 | endif(ZLIB_BUILD_SHARED) | 119 | endif(ZLIB_BUILD_SHARED) |
| 138 | 120 | ||
| 139 | if(ZLIB_BUILD_STATIC) | 121 | if(ZLIB_BUILD_STATIC) |
| 140 | add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) | 122 | add_library(zlibstatic STATIC |
| 123 | ${ZLIB_SRCS} | ||
| 124 | ${ZLIB_PUBLIC_HDRS} | ||
| 125 | ${ZLIB_PRIVATE_HDRS}) | ||
| 141 | target_include_directories(zlibstatic PUBLIC | 126 | target_include_directories(zlibstatic PUBLIC |
| 142 | $<BUILD_INTERFACE:${zlib_BINARY_DIR}> | 127 | $<BUILD_INTERFACE:${zlib_BINARY_DIR}> |
| 143 | $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>) | 128 | $<BUILD_INTERFACE:${zlib_SOURCE_DIR}>) |
