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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. From 990835b15e3713e6c34d64b4bed8e55dcca6e6e2 Mon Sep 17 00:00:00 2001
  2. From: Samuel Martin <s.martin49@gmail.com>
  3. Date: Sat, 30 Aug 2014 00:40:03 +0200
  4. Subject: [PATCH 2/2] cmake: disable shared library build when
  5. BUILD_SHARED_LIBS is off
  6. Signed-off-by: Samuel Martin <s.martin49@gmail.com>
  7. ---
  8. CMakeLists.txt | 19 +++++++++++++------
  9. 1 file changed, 13 insertions(+), 6 deletions(-)
  10. diff --git a/CMakeLists.txt b/CMakeLists.txt
  11. index 72391b0..8f28680 100644
  12. --- a/CMakeLists.txt
  13. +++ b/CMakeLists.txt
  14. @@ -320,14 +320,19 @@ source_group("Sources" FILES ${SOURCES})
  15. #
  16. # Create the lib.
  17. #
  18. +set(_libs_websockets websockets)
  19. add_library(websockets STATIC
  20. ${HDR_PRIVATE}
  21. ${HDR_PUBLIC}
  22. ${SOURCES})
  23. +
  24. +if(BUILD_SHARED_LIBS)
  25. +list(APPEND _libs_websockets websockets_shared)
  26. add_library(websockets_shared SHARED
  27. ${HDR_PRIVATE}
  28. ${HDR_PUBLIC}
  29. ${SOURCES})
  30. +endif()
  31. if (WIN32)
  32. # On Windows libs have the same file ending (.lib)
  33. @@ -348,15 +353,17 @@ endif(WIN32)
  34. # We want the shared lib to be named "libwebsockets"
  35. # not "libwebsocket_shared".
  36. +if(BUILD_SHARED_LIBS)
  37. set_target_properties(websockets_shared
  38. - PROPERTIES
  39. + PROPERTIES
  40. OUTPUT_NAME websockets)
  41. +endif()
  42. # Set the so version of the lib.
  43. # Equivalent to LDFLAGS=-version-info x:x:x
  44. if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
  45. - foreach(lib websockets websockets_shared)
  46. - set_target_properties(${lib}
  47. + foreach(lib ${_libs_websockets})
  48. + set_target_properties(${lib}
  49. PROPERTIES
  50. SOVERSION ${SOVERSION})
  51. endforeach()
  52. @@ -408,7 +415,7 @@ if (NOT WITHOUT_EXTENSIONS)
  53. endif()
  54. # Make sure ZLib is compiled before the libs.
  55. - foreach (lib websockets websockets_shared)
  56. + foreach (lib ${_libs_websockets})
  57. add_dependencies(${lib} ZLIB)
  58. endforeach()
  59. @@ -462,7 +469,7 @@ if (UNIX)
  60. endif()
  61. # Setup the linking for all libs.
  62. -foreach (lib websockets websockets_shared)
  63. +foreach (lib ${_libs_websockets})
  64. target_link_libraries(${lib} ${LIB_LIST})
  65. endforeach()
  66. @@ -727,7 +734,7 @@ install(FILES ${HDR_PUBLIC}
  67. set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Header files")
  68. # Install libs.
  69. -install(TARGETS websockets websockets_shared
  70. +install(TARGETS ${_libs_websockets}
  71. LIBRARY DESTINATION lib${LIB_SUFFIX}
  72. ARCHIVE DESTINATION lib${LIB_SUFFIX}
  73. COMPONENT libraries)
  74. --
  75. 2.1.0