libwebsockets-0002-cmake-disable-shared-library-build-when-BUILD_SHARED.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. ---
  11. CMakeLists.txt | 17 ++++++++++++-----
  12. 1 file changed, 12 insertions(+), 5 deletions(-)
  13. diff --git a/CMakeLists.txt b/CMakeLists.txt
  14. index 7978845..89853ce 100644
  15. --- a/CMakeLists.txt
  16. +++ b/CMakeLists.txt
  17. @@ -372,14 +372,19 @@ source_group("Sources" FILES ${SOURCES})
  18. #
  19. # Create the lib.
  20. #
  21. +set(_libs_websockets websockets)
  22. add_library(websockets STATIC
  23. ${HDR_PRIVATE}
  24. ${HDR_PUBLIC}
  25. ${SOURCES})
  26. +
  27. +if(BUILD_SHARED_LIBS)
  28. +list(APPEND _libs_websockets websockets_shared)
  29. add_library(websockets_shared SHARED
  30. ${HDR_PRIVATE}
  31. ${HDR_PUBLIC}
  32. ${SOURCES})
  33. +endif()
  34. if (WIN32)
  35. # On Windows libs have the same file ending (.lib)
  36. @@ -400,15 +405,17 @@ endif(WIN32)
  37. # We want the shared lib to be named "libwebsockets"
  38. # not "libwebsocket_shared".
  39. +if(BUILD_SHARED_LIBS)
  40. set_target_properties(websockets_shared
  41. - PROPERTIES
  42. + PROPERTIES
  43. OUTPUT_NAME websockets)
  44. +endif()
  45. # Set the so version of the lib.
  46. # Equivalent to LDFLAGS=-version-info x:x:x
  47. if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
  48. - foreach(lib websockets websockets_shared)
  49. - set_target_properties(${lib}
  50. + foreach(lib ${_libs_websockets})
  51. + set_target_properties(${lib}
  52. PROPERTIES
  53. SOVERSION ${SOVERSION})
  54. endforeach()
  55. @@ -460,7 +467,7 @@ if (NOT LWS_WITHOUT_EXTENSIONS)
  56. endif()
  57. # Make sure ZLib is compiled before the libs.
  58. - foreach (lib websockets websockets_shared)
  59. + foreach (lib ${_libs_websockets})
  60. add_dependencies(${lib} ZLIB)
  61. endforeach()
  62. @@ -524,7 +531,7 @@ if (UNIX)
  63. endif()
  64. # Setup the linking for all libs.
  65. -foreach (lib websockets websockets_shared)
  66. +foreach (lib ${_libs_websockets})
  67. target_link_libraries(${lib} ${LIB_LIST})
  68. endforeach()
  69. --
  70. 2.1.2