2022-10-26 01:24:48 +08:00
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
|
|
--- a/CMakeLists.txt
|
|
|
|
+++ b/CMakeLists.txt
|
2024-01-31 04:58:10 +08:00
|
|
|
@@ -123,9 +123,11 @@ set(ZLIB_SRCS
|
2022-10-26 01:24:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT MINGW)
|
|
|
|
+ if(BUILD_SHARED_LIBS)
|
|
|
|
set(ZLIB_DLL_SRCS
|
|
|
|
win32/zlib1.rc # If present will override custom build rule below.
|
|
|
|
)
|
|
|
|
+ endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
|
2024-01-31 04:58:10 +08:00
|
|
|
@@ -146,15 +148,17 @@ if(MINGW)
|
2022-10-26 01:24:48 +08:00
|
|
|
-I ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
|
|
|
|
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
|
|
|
|
+ if(BUILD_SHARED_LIBS)
|
|
|
|
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
|
|
|
|
+ endif()
|
|
|
|
endif(MINGW)
|
|
|
|
|
|
|
|
-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
|
|
|
+add_library(zlib ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
2024-01-31 04:58:10 +08:00
|
|
|
target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
|
|
|
-target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
2022-10-26 01:24:48 +08:00
|
|
|
+if (BUILD_SHARED_LIBS)
|
|
|
|
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
|
|
|
|
set_target_properties(zlib PROPERTIES SOVERSION 1)
|
|
|
|
+endif()
|
|
|
|
|
|
|
|
if(NOT CYGWIN)
|
|
|
|
# This property causes shared libraries on Linux to have the full version
|
2024-01-31 04:58:10 +08:00
|
|
|
@@ -169,7 +173,7 @@ endif()
|
2022-10-26 01:24:48 +08:00
|
|
|
|
|
|
|
if(UNIX)
|
|
|
|
# On unix-like platforms the library is almost always called libz
|
|
|
|
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
|
|
|
|
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
|
2024-01-31 04:58:10 +08:00
|
|
|
if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
|
2022-10-26 01:24:48 +08:00
|
|
|
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
|
|
|
|
endif()
|
2024-01-31 04:58:10 +08:00
|
|
|
@@ -179,7 +183,7 @@ elseif(BUILD_SHARED_LIBS AND WIN32)
|
2022-10-26 01:24:48 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
|
|
|
- install(TARGETS zlib zlibstatic
|
2024-01-31 04:58:10 +08:00
|
|
|
+ install(TARGETS zlib
|
2022-10-26 01:24:48 +08:00
|
|
|
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
|
|
|
|
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
|
|
|
|
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
|