0003-build-static-or-shared-not-both.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index f46c8e6..6fa5575 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -121,9 +121,11 @@ set(ZLIB_SRCS
  6. )
  7. if(NOT MINGW)
  8. + if(BUILD_SHARED_LIBS)
  9. set(ZLIB_DLL_SRCS
  10. win32/zlib1.rc # If present will override custom build rule below.
  11. )
  12. + endif()
  13. endif()
  14. # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
  15. @@ -144,13 +146,16 @@ if(MINGW)
  16. -I ${CMAKE_CURRENT_BINARY_DIR}
  17. -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
  18. -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
  19. + if(BUILD_SHARED_LIBS)
  20. set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
  21. + endif()
  22. endif(MINGW)
  23. -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
  24. -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
  25. +add_library(zlib ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
  26. +if (BUILD_SHARED_LIBS)
  27. set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
  28. set_target_properties(zlib PROPERTIES SOVERSION 1)
  29. +endif()
  30. if(NOT CYGWIN)
  31. # This property causes shared libraries on Linux to have the full version
  32. @@ -165,7 +170,7 @@ endif()
  33. if(UNIX)
  34. # On unix-like platforms the library is almost always called libz
  35. - set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
  36. + set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
  37. if(NOT APPLE)
  38. set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
  39. endif()
  40. @@ -175,7 +180,7 @@ elseif(BUILD_SHARED_LIBS AND WIN32)
  41. endif()
  42. if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
  43. - install(TARGETS zlib zlibstatic
  44. + install(TARGETS zlib
  45. RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
  46. ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
  47. LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )