Debian Codegraph @

LspCpp/third_party/ixwebsocket/docs/build.md

raw
1 ## Build
2
3 ### Building static libraries
4
5 A static library can be build using:
6 ```
7 mkdir build #make a build dir so that you can build out of tree
8 cd build
9 cmake -DUSE_TLS=1 ..
10 make -j
11 ```
12 There are also two build scripts in the `tools` folder for creating static libraries for android and iOS/macOS respectively.<br>
13 Arguments can be changed in the script files.
14
15 Android:
16 ```
17 mkdir build
18 cd build
19 ./../tools/build_android.sh
20 make -j
21 ```
22 macOS & iOS:
23 ```
24 mkdir build
25 cd build
26 ./../tools/build_ios.sh
27 ```
28
29 ### CMake
30
31 CMakefiles for the library and the examples are available. This library has few dependencies, so it is possible to just add the source files into your project. Otherwise the usual way will suffice.
32
33 ```
34 mkdir build
35 cd build
36 cmake -DUSE_TLS=1 ..
37 make -j
38 make install # will install to /usr/local on Unix, on macOS it is a good idea to sudo chown -R `whoami`:staff /usr/local
39 ```
40
41 Headers and a static library will be installed to the target dir.
42 There is a unittest which can be executed by typing `make test`.
43
44 Options for building:
45
46 * `-DBUILD_SHARED_LIBS=ON` will build the unittest as a shared libary instead of a static library, which is the default
47 * `-DUSE_ZLIB=1` will enable zlib support, required for http client + server + websocket per message deflate extension
48 * `-DUSE_TLS=1` will enable TLS support
49 * `-DUSE_OPEN_SSL=1` will use [openssl](https://www.openssl.org/) for the TLS support (default on Linux and Windows). When using a custom version of openssl (say a prebuilt version, odd runtime problems can happens, as in #319, and special cmake trickery will be required (see this [comment](https://github.com/machinezone/IXWebSocket/issues/175#issuecomment-620231032))
50 * `-DUSE_MBED_TLS=1` will use [mbedlts](https://tls.mbed.org/) for the TLS support
51 * `-DUSE_WS=1` will build the ws interactive command line tool
52 * `-DUSE_TEST=1` will build the unittest
53
54 If you are on Windows, look at the [appveyor](https://github.com/machinezone/IXWebSocket/blob/master/appveyor.yml) file (not maintained much though) or rather the [github actions](https://github.com/machinezone/IXWebSocket/blob/master/.github/workflows/unittest_windows.yml) which have instructions for building dependencies.
55
56 It is also possible to externally include the project, so that everything is fetched over the wire when you build like so:
57
58 ```
59 ExternalProject_Add(
60 IXWebSocket
61 GIT_REPOSITORY https://github.com/machinezone/IXWebSocket.git
62 ...
63 )
64 ```
65
66 ### vcpkg
67
68 It is possible to get IXWebSocket through Microsoft [vcpkg](https://github.com/microsoft/vcpkg).
69
70 ```
71 vcpkg install ixwebsocket
72 ```
73 To use the installed package within a cmake project, use the following:
74 ```cmake
75 set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") # this is super important in order for cmake to include the vcpkg search/lib paths!
76
77 # find library and its headers
78 find_path(IXWEBSOCKET_INCLUDE_DIR ixwebsocket/IXWebSocket.h)
79 find_library(IXWEBSOCKET_LIBRARY ixwebsocket)
80 # include headers
81 include_directories(${IXWEBSOCKET_INCLUDE_DIR})
82 # ...
83 target_link_libraries(${PROJECT_NAME} ... ${IXWEBSOCKET_LIBRARY}) # Cmake will automatically fail the generation if the lib was not found, i.e is set to NOTFOUND
84
85 ```
86
87 ### Conan
88
89 [ ![Download](https://api.bintray.com/packages/conan/conan-center/ixwebsocket%3A_/images/download.svg) ](https://bintray.com/conan/conan-center/ixwebsocket%3A_/_latestVersion)
90
91 Conan is currently supported through a recipe in [Conan Center](https://github.com/conan-io/conan-center-index/tree/master/recipes/ixwebsocket) ([Bintray entry](https://bintray.com/conan/conan-center/ixwebsocket%3A_)).
92
93 Package reference
94
95 * Conan 1.21.0 and up: `ixwebsocket/7.9.2`
96 * Earlier versions: `ixwebsocket/7.9.2@_/_`
97
98 Note that the version listed here might not be the latest one. See Bintray or the recipe itself for the latest version. If you're migrating from the previous, custom Bintray remote, note that the package reference _has_ to be lower-case.
99
100 ### Docker
101
102 There is a Dockerfile for running the unittest on Linux, and to run the `ws` tool. It is also available on the docker registry.
103
104 ```
105 docker run docker.pkg.github.com/machinezone/ixwebsocket/ws:latest --help
106 ```
107
108 To use docker-compose you must make a docker container first.
109
110 ```
111 $ make docker
112 ...
113 $ docker compose up &
114 ...
115 $ docker exec -it ixwebsocket_ws_1 bash
116 app@ca2340eb9106:~$ ws --help
117 ws is a websocket tool
118 ...
119 ```