I want to build EchoServer.cpp
example of uWebsockets
C++ library using vcpkg manifest mode.
my-app
│ CMakeLists.txt
│ vcpkg.json
│
└───examples
CMakeLists.txt
EchoServer.cpp
Contents of vcpkg.json
:
{
"name": "myfirst",
"version-string": "1.0.0",
"dependencies": [
"uwebsockets"
]
}
Contents of CMakeLists.txt
:
cmake_minimum_required(VERSION 3.24)
project(my-app VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
find_path(UWEBSOCKETS_INCLUDE_DIRS "uwebsockets/App.h")
add_subdirectory(examples)
Contents of examples\CMakeLists.txt
:
cmake_minimum_required(VERSION 3.24)
project(projExamples VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 20)
add_executable(EchoServerExample EchoServer.cpp)
target_include_directories(EchoServerExample PRIVATE ${UWEBSOCKETS_INCLUDE_DIRS})
The toolchain is properly passed to my CLion IDE by "DCMAKE_TOOLCHAIN_FILE=C:\Dev\vcpkg\scripts\buildsystems\vcpkg.cmake"
. When I configure my project, vcpkg works correctly and installs uWebsockets
and prints the following message:
...
The following packages will be built and installed:
* libuv[core]:x64-windows -> 1.46.0
* usockets[core]:x64-windows -> 0.8.6#1
uwebsockets[core]:x64-windows -> 20.45.0
* vcpkg-cmake[core]:x64-windows -> 2023-05-04
* vcpkg-cmake-config[core]:x64-windows -> 2022-02-06#1
* zlib[core]:x64-windows -> 1.2.13
...
find_path(UWEBSOCKETS_INCLUDE_DIRS "uwebsockets/App.h")
target_include_directories(main PRIVATE ${UWEBSOCKETS_INCLUDE_DIRS})
I don't know how I should utilize uWebsockets
in the CMakeLists.txt
in example subdirectory. Because of this, I am getting the following error when I run EchoServerExample.exe
. It appears to me that it is not able to find the dependencies of uWebsockets
: zlib
, uv
, uSockets
.
LINK : fatal error LNK1104: cannot open file 'uv.lib'
Is this the correct way of integrating uWebsockets
into my project directory using vcpkg.json
? Could someone kindly help? Thanks in advance.