0001-Respect-BUILD_SHARED_LIBS.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From 0c64e33bc2e4e7c011f5a64f5d9c7571a434cc86 Mon Sep 17 00:00:00 2001
  2. From: tamasmeszaros <meszaros.q@gmail.com>
  3. Date: Sat, 16 Nov 2019 13:43:17 +0100
  4. Subject: [PATCH] Respect BUILD_SHARED_LIBS
  5. ---
  6. CMakeLists.txt | 14 ++++++++------
  7. 1 file changed, 8 insertions(+), 6 deletions(-)
  8. diff --git a/CMakeLists.txt b/CMakeLists.txt
  9. index 0fe939d..01dfea1 100644
  10. --- a/CMakeLists.txt
  11. +++ b/CMakeLists.txt
  12. @@ -183,10 +183,12 @@ if(MINGW)
  13. set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
  14. endif(MINGW)
  15. -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
  16. -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
  17. -set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
  18. -set_target_properties(zlib PROPERTIES SOVERSION 1)
  19. +add_library(zlib ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
  20. +if (BUILD_SHARED_LIBS)
  21. + target_sources(zlib PRIVATE ${ZLIB_DLL_SRCS})
  22. + set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
  23. + set_target_properties(zlib PROPERTIES SOVERSION 1)
  24. +endif()
  25. if(NOT CYGWIN)
  26. # This property causes shared libraries on Linux to have the full version
  27. @@ -201,7 +203,7 @@ endif()
  28. if(UNIX)
  29. # On unix-like platforms the library is almost always called libz
  30. - set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
  31. + set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
  32. if(NOT APPLE)
  33. set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
  34. endif()
  35. @@ -211,7 +213,7 @@ elseif(BUILD_SHARED_LIBS AND WIN32)
  36. endif()
  37. if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
  38. - install(TARGETS zlib zlibstatic
  39. + install(TARGETS zlib
  40. RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
  41. ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
  42. LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
  43. --
  44. 2.16.2.windows.1