This repo is an adaptation of µWebSocket.
It has been made to enable the compilation of uws with CMake, which is no longer supported by the author.
This post has been a very useful resource during the adaptation for the CMake build process.
Other files have been created to help the integration of uws to any other CMake project (Located in the cmake-files-for-other-projects-using-uws folder)
Googletest's cmake integration page has been particularly useful for this part.
Note that this project has some dependencies:
- cmake
- libuv
- pthread
- pkgConfig
- openssl
- zlib
Make sure all the dependencies are installed, otherwise uws won't be built!
Copy the content of the cmake-files-for-other-projects-using-uws folder to the root of your CMake project.
NB:
- You can actually place this
cmake-modulefolder wherever you like, although we recommend the project's root directory for simplicity and cleanness.- You can always rename
cmake-moduleand the other macros to something else, but make sure to rename them in every files!
It contains cmake macros to simplify the integration of a git project in CMake. Then, add the following lines to your root CMakeLists.txt somewhere near the top:
... # Integration of cmake macros and custom functions include(cmake-module/setupCMakeMacros.cmake) setup_cmake_macros(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) ... You can take a look in the cmake-module/setupCMakeMacros.cmake to know what exactly gets loaded.
You can then drop those lines where you build your CMake target:
# uws fetch_uws( ${PROJECT_SOURCE_DIR}/cmake-module ${PROJECT_BINARY_DIR}/lib/uws ) target_link_libraries(${PROJECT_NAME} ... uws) ... and your done!
- Download the project
- In the base
uws/directory, run :
mkdir cmake-build-debug cd cmake-build-debug cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - UnixMakefile" .. make && sudo make install If everything goes according to plan, you should then be able to include the uws by adding this to your CMakeLists.txt:
find_package(uws CONFIG REQUIRED) if (uws_FOUND) message(STATUS "Found uws") message(STATUS "uws libraries path: ${uws_LIBRARIES}") message(STATUS "uws headers directory: ${uws_INCLUDE_DIRS}") else () message(FATAL "uws is required") endif () include_directories(${uws_INCLUDE_DIRS}) target_link_libraries(**YOUR TARGET NAME HERE!!** uws) Apache-2.0