0001-cmake-disable-shared-library-build-when-BUILD_SHARED.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. From 045b035bd9ebbd45f40dda36b143ede869eb5f16 Mon Sep 17 00:00:00 2001
  2. From: Sagaert Johan <sagaert.johan@skynet.be>
  3. Date: Fri, 31 Oct 2014 12:25:48 +0100
  4. Subject: [PATCH 2/2] cmake: disable shared library build when
  5. BUILD_SHARED_LIBS is off
  6. Original patch from Samuel Martin, reworked by Sagaert Johan when
  7. updating libwebsockets.
  8. Signed-off-by: Samuel Martin <s.martin49@gmail.com>
  9. Signed-off-by: Sagaert Johan <sagaert.johan@skynet.be>
  10. [yann.morin.1998@free.fr: further fix after the version bumped]
  11. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
  12. ---
  13. CMakeLists.txt | 17 ++++++++++++-----
  14. 1 file changed, 12 insertions(+), 5 deletions(-)
  15. diff --git a/CMakeLists.txt b/CMakeLists.txt
  16. index 7978845..89853ce 100644
  17. --- a/CMakeLists.txt
  18. +++ b/CMakeLists.txt
  19. @@ -372,14 +372,19 @@ source_group("Sources" FILES ${SOURCES})
  20. #
  21. # Create the lib.
  22. #
  23. +set(_libs_websockets websockets)
  24. add_library(websockets STATIC
  25. ${HDR_PRIVATE}
  26. ${HDR_PUBLIC}
  27. ${SOURCES})
  28. +
  29. +if(BUILD_SHARED_LIBS)
  30. +list(APPEND _libs_websockets websockets_shared)
  31. add_library(websockets_shared SHARED
  32. ${HDR_PRIVATE}
  33. ${HDR_PUBLIC}
  34. ${SOURCES})
  35. +endif()
  36. if (WIN32)
  37. # On Windows libs have the same file ending (.lib)
  38. @@ -400,15 +405,17 @@ endif(WIN32)
  39. # We want the shared lib to be named "libwebsockets"
  40. # not "libwebsocket_shared".
  41. +if(BUILD_SHARED_LIBS)
  42. set_target_properties(websockets_shared
  43. - PROPERTIES
  44. + PROPERTIES
  45. OUTPUT_NAME websockets)
  46. +endif()
  47. # Set the so version of the lib.
  48. # Equivalent to LDFLAGS=-version-info x:x:x
  49. if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
  50. - foreach(lib websockets websockets_shared)
  51. - set_target_properties(${lib}
  52. + foreach(lib ${_libs_websockets})
  53. + set_target_properties(${lib}
  54. PROPERTIES
  55. SOVERSION ${SOVERSION})
  56. endforeach()
  57. @@ -460,7 +467,7 @@ if (NOT LWS_WITHOUT_EXTENSIONS)
  58. endif()
  59. # Make sure ZLib is compiled before the libs.
  60. - foreach (lib websockets websockets_shared)
  61. + foreach (lib ${_libs_websockets})
  62. add_dependencies(${lib} ZLIB)
  63. endforeach()
  64. @@ -524,7 +531,7 @@ if (UNIX)
  65. endif()
  66. # Setup the linking for all libs.
  67. -foreach (lib websockets websockets_shared)
  68. +foreach (lib ${_libs_websockets})
  69. target_link_libraries(${lib} ${LIB_LIST})
  70. endforeach()
  71. @@ -793,7 +800,7 @@
  72. set(LWS_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
  73. # Export targets (This is used for other CMake projects to easily find the libraries and include files).
  74. -export(TARGETS websockets websockets_shared
  75. +export(TARGETS ${_libs_websockets}
  76. FILE "${PROJECT_BINARY_DIR}/LibwebsocketsTargets.cmake")
  77. export(PACKAGE libwebsockets)
  78. @@ -829,7 +835,7 @@
  79. ${PROJECT_BINARY_DIR}/LibwebsocketsConfigVersion.cmake
  80. @ONLY)
  81. -set_target_properties(websockets websockets_shared
  82. +set_target_properties(${_libs_websockets}
  83. PROPERTIES PUBLIC_HEADER "${HDR_PUBLIC}")
  84. #
  85. @@ -837,7 +843,7 @@
  86. #
  87. # Install libs and headers.
  88. -install(TARGETS websockets websockets_shared
  89. +install(TARGETS ${_libs_websockets}
  90. EXPORT LibwebsocketsTargets
  91. LIBRARY DESTINATION "${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}" COMPONENT libraries
  92. ARCHIVE DESTINATION "${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}" COMPONENT libraries