Add package libwebsockets

See #442 and #445.

Initial patch based on: Sergey <non_2001@mail.ru>

Modifications:
- fix update macro
- disable on MinGW32
- fix lib installation (w/o the patch it builds both shared/static)
- use system zlib

Signed-off-by: Timothy Gu <timothygu99@gmail.com>
This commit is contained in:
Timothy Gu 2014-08-05 18:47:44 -07:00
parent c6e5480b0e
commit 3caf14807e
3 changed files with 196 additions and 0 deletions

View File

@ -1777,6 +1777,10 @@ local-pkg-list: $(LOCAL_PKG_LIST)</pre>
<td class="package">libvpx</td>
<td class="website"><a href="http://code.google.com/p/webm/">vpx</a></td>
</tr>
<tr>
<td class="package">libwebsockets</td>
<td class="website"><a href="http://libwebsockets.org/">libwebsockets</a></td>
</tr>
<tr>
<td class="package">libxml++</td>
<td class="website"><a href="http://libxmlplusplus.sourceforge.net/">libxml2</a></td>

View File

@ -0,0 +1,164 @@
This file is part of MXE.
See index.html for further information.
From e34eaa834b15533c6280b67d93d505432bd2fa94 Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Mon, 4 Aug 2014 18:28:33 -0700
Subject: [PATCH] Remove the special _shared lib
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff9a24e..962df28 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -372,43 +372,41 @@ source_group("Sources" FILES ${SOURCES})
#
# Create the lib.
#
-add_library(websockets STATIC
- ${HDR_PRIVATE}
- ${HDR_PUBLIC}
- ${SOURCES})
-add_library(websockets_shared SHARED
+add_library(websockets
${HDR_PRIVATE}
${HDR_PUBLIC}
${SOURCES})
if (WIN32)
- # On Windows libs have the same file ending (.lib)
- # for both static and shared libraries, so we
- # need a unique name for the static one.
- set_target_properties(websockets
- PROPERTIES
- OUTPUT_NAME websockets_static)
-
- # Compile as DLL (export function declarations)
- set_property(
- TARGET websockets_shared
- PROPERTY COMPILE_DEFINITIONS
- LWS_DLL
- LWS_INTERNAL
- )
+# # On Windows libs have the same file ending (.lib)
+# # for both static and shared libraries, so we
+# # need a unique name for the static one.
+# set_target_properties(websockets
+# PROPERTIES
+# OUTPUT_NAME websockets_static)
+
+ if (BUILD_SHARED_LIBS)
+ # Compile as DLL (export function declarations)
+ set_property(
+ TARGET websockets
+ PROPERTY COMPILE_DEFINITIONS
+ LWS_DLL
+ LWS_INTERNAL
+ )
+ endif (BUILD_SHARED_LIBS)
endif(WIN32)
# We want the shared lib to be named "libwebsockets"
# not "libwebsocket_shared".
-set_target_properties(websockets_shared
- PROPERTIES
- OUTPUT_NAME websockets)
+# set_target_properties(websockets_shared
+# PROPERTIES
+# OUTPUT_NAME websockets)
# Set the so version of the lib.
# Equivalent to LDFLAGS=-version-info x:x:x
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
- foreach(lib websockets websockets_shared)
- set_target_properties(${lib}
+ foreach(lib websockets)
+ set_target_properties(${lib}
PROPERTIES
SOVERSION ${SOVERSION})
endforeach()
@@ -460,7 +458,7 @@ if (NOT LWS_WITHOUT_EXTENSIONS)
endif()
# Make sure ZLib is compiled before the libs.
- foreach (lib websockets websockets_shared)
+ foreach (lib websockets)
add_dependencies(${lib} ZLIB)
endforeach()
@@ -524,7 +522,7 @@ if (UNIX)
endif()
# Setup the linking for all libs.
-foreach (lib websockets websockets_shared)
+foreach (lib websockets)
target_link_libraries(${lib} ${LIB_LIST})
endforeach()
@@ -557,11 +555,8 @@ if (NOT LWS_WITHOUT_TESTAPPS)
source_group("Headers Private" FILES ${TEST_HDR})
source_group("Sources" FILES ${TEST_SRCS})
add_executable(${TEST_NAME} ${TEST_SRCS} ${TEST_HDR})
-
- if (LWS_LINK_TESTAPPS_DYNAMIC)
- target_link_libraries(${TEST_NAME} websockets_shared)
- add_dependencies(${TEST_NAME} websockets_shared)
- else(LWS_LINK_TESTAPPS_DYNAMIC)
+
+ if (NOT LWS_LINK_TESTAPPS_DYNAMIC)
target_link_libraries(${TEST_NAME} websockets)
add_dependencies(${TEST_NAME} websockets)
endif(LWS_LINK_TESTAPPS_DYNAMIC)
@@ -793,7 +788,7 @@ endif()
set(LWS_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
# Export targets (This is used for other CMake projects to easily find the libraries and include files).
-export(TARGETS websockets websockets_shared
+export(TARGETS websockets
FILE "${PROJECT_BINARY_DIR}/LibwebsocketsTargets.cmake")
export(PACKAGE libwebsockets)
@@ -829,7 +824,7 @@ configure_file(${PROJECT_SOURCE_DIR}/cmake/LibwebsocketsConfigVersion.cmake.in
${PROJECT_BINARY_DIR}/LibwebsocketsConfigVersion.cmake
@ONLY)
-set_target_properties(websockets websockets_shared
+set_target_properties(websockets
PROPERTIES PUBLIC_HEADER "${HDR_PUBLIC}")
#
@@ -837,7 +832,7 @@ set_target_properties(websockets websockets_shared
#
# Install libs and headers.
-install(TARGETS websockets websockets_shared
+install(TARGETS websockets
EXPORT LibwebsocketsTargets
LIBRARY DESTINATION "${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}" COMPONENT libraries
ARCHIVE DESTINATION "${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}" COMPONENT libraries
@@ -906,9 +901,8 @@ message(" LWS_WITH_HTTP2 = ${LWS_WITH_HTTP2}")
message("---------------------------------------------------------------------")
# These will be available to parent projects including libwebsockets using add_subdirectory()
-set(LIBWEBSOCKETS_LIBRARIES websocket websockets_shared CACHE STRING "Libwebsocket libraries")
+set(LIBWEBSOCKETS_LIBRARIES websocket CACHE STRING "Libwebsocket libraries")
set(LIBWEBSOCKETS_LIBRARIES_STATIC websocket CACHE STRING "Libwebsocket static library")
-set(LIBWEBSOCKETS_LIBRARIES_SHARED websockets_shared CACHE STRING "Libwebsocket shared library")
# This must always be last!
include(CPack)
diff --git a/cmake/LibwebsocketsConfig.cmake.in b/cmake/LibwebsocketsConfig.cmake.in
index bea82b5..6973fbf 100644
--- a/cmake/LibwebsocketsConfig.cmake.in
+++ b/cmake/LibwebsocketsConfig.cmake.in
@@ -13,5 +13,5 @@ set(LIBWEBSOCKETS_INCLUDE_DIRS "@LWS__INCLUDE_DIRS@")
include(${LWS_CMAKE_DIR}/LibwebsocketsTargets.cmake)
# IMPORTED targets from LibwebsocketsTargets.cmake
-set(LIBWEBSOCKETS_LIBRARIES websockets websockets_shared)
+set(LIBWEBSOCKETS_LIBRARIES websockets)
--
1.9.1

28
src/libwebsockets.mk Normal file
View File

@ -0,0 +1,28 @@
# This file is part of MXE.
# See index.html for further information.
PKG := libwebsockets
$(PKG)_IGNORE :=
$(PKG)_VERSION := 1.3-chrome37-firefox30
$(PKG)_CHECKSUM := ee1005165346d2217db4a9c40c4711f741213557
$(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION)
$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.gz
$(PKG)_URL := http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/snapshot/$($(PKG)_FILE)
$(PKG)_DEPS := gcc openssl zlib
define $(PKG)_UPDATE
echo 'TODO: write update script for libwebsockets.' >&2;
echo $(libwebsockets_VERSION)
endef
define $(PKG)_BUILD
cd '$(1)' && cmake \
-DLWS_WITHOUT_TESTAPPS=ON \
-DLWS_USE_EXTERNAL_ZLIB=ON \
-DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)'
$(MAKE) -C '$(1)' -j $(JOBS)
$(MAKE) -C '$(1)' install
endef
# MinGW 32 lacks mstcpip.h
$(PKG)_BUILD_i686-pc-mingw32 =