[Libwebsockets] howto build minimal example

Michael Johanssen Michael.Johanssen at web.de
Sat Nov 14 20:23:55 CET 2020


Hi - let me start with stating that I am a real beginner. So I am
working under Windows, of course.

I managed cloning the git repository, configure, generate, build and
install the basic installation w/o any cmake adaptations.
libwebsockets-test-server.exe and libwebsockets-test-client.exe seem to
work as intended.
However, now when trying to build the minimal-ws-server-timer example,
cmake fails:

CMake Error at C:/Projects/install/cmake/LwsCheckRequirements.cmake:52
(message):
   This project requires lws must have been configured with LWS_ROLE_WS

I think the error is caused because I do not know how to tell cmake
where the libwebsockets install resides.

In the libwebsockets/minimal-examples/ws-server/minimal-ws-server-timer
directory, I call:

cmake -B build -S . -DCMAKE_PREFIX_PATH="c:/Projects/install"

So my question is: What would be a correct invocation (presumably, which
variable setting(s)) that causes CMake to set respective include
directories ?

Details:
CMakeError.log:
   ...
   cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D WIN32 /D _WINDOWS
/D HAS_LWS_ROLE_WS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd
/GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline
/Fo"cmTC_02f8c.dir\Debug\\" /Fd"cmTC_02f8c.dir\Debug\vc142.pdb" /Gd /TC
/errorReport:queue
"C:\Projects\libs\libwebsockets\minimal-examples\ws-server\minimal-ws-server-timer\build\CMakeFiles\CMakeTmp\src.c"

C:\Projects\libs\libwebsockets\minimal-examples\ws-server\minimal-ws-server-timer\build\CMakeFiles\CMakeTmp\src.c(1,10):
fatal error C1083: *Datei (Include) kann nicht geöffnet werden:
"libwebsockets.h"*: No such file or directory
[C:\Projects\libs\libwebsockets\minimal-examples\ws-server\minimal-ws-server-timer\build\CMakeFiles\CMakeTmp\cmTC_02f8c.vcxproj]


So libwebsockets.h is not found - apparently because cmake does not set
include directories as needed.
The minimal-ws-server-timer CMakeLists.txt file contains:
...
require_lws_config(LWS_ROLE_WS 1 requirements)
require_lws_config(LWS_WITH_SERVER 1 requirements)
...
Within require_lws_config(...), the compile is triggered by means of a
CHECK_C_SOURCE_COMPILES(...) macro call within
LwsCheckRequirements.cmake. I check respective CMake variables.

For debugging purposes, I put two printouts before the
require_lws_config call, resulting in:
INCLUDE_DIRECTORIES=
CMAKE_REQUIRED_INCLUDES=
Both variables are empty. I could set INCLUDE_DIRECTORIES by changing in
libwebsockets-config.cmake:
set(LIBWEBSOCKETS_INCLUDE_DIRS "")
to
set(LIBWEBSOCKETS_INCLUDE_DIRS "c:/Projects/include")
However, this did not help.

The install directory is structured as follows:
- bin
- cmake
     libwebsockets-config.cmake
     libwebsockets-config-version.cmake
     LibwebsocketsTargets.cmake
     LibwebsocketsTargets-release.cmake
     LwsCheckRequirements.cmake
- include
     libwebsockets.h
     libwebsockets
       <all the lws-xxx.h> files
- lib
- share

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20201114/113537d6/attachment.htm>


More information about the Libwebsockets mailing list