1 (edited by r-type 2022-04-25 03:42:46)

Topic: Extending CMakeLists.txt to support libwebsockets

Hi,
we  are building all third party libs with cmake in our build environment I'm going to switch wolfSSL build to cmake. Currently there is no support for --enable-libwebsockets in CMakeLists.txt. I had a look on configure.ac and it seems that adding

-DWOLFSSL_LIBWEBSOCKETS -DHAVE_EX_DATA -DOPENSSL_NO_EC

would be enough. Should I put this into WOLFSSL_DEFINITIONS? Something like this:

add_option("WOLFSSL_LIBWEBSOCKETS"
"Enables libwebsockets support (default: disabled)"
    "no" "yes;no")
if(WOLFSSL_LIBWEBSOCKETS )
    list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_LIBWEBSOCKETS" "-DHAVE_EX_DATA" "-DOPENSSL_NO_EC")
endif()

Share

Re: Extending CMakeLists.txt to support libwebsockets

Hi r-type,

Yes, you can modify the CMakeLists.txt. Our CMake build is a work-in-progress. Alternatively, you can also pass in wolfSSL build options like this:

cmake ../wolfssl -DCMAKE_C_FLAGS_INIT='-DWOLFSSL_LIBWEBSOCKETS -DHAVE_EX_DATA -DOPENSSL_NO_EC'

Re: Extending CMakeLists.txt to support libwebsockets

Hi embhorn,
thanks for reply. It works with CMakeLists.txt modification, but now I tried it with -DCMAKE_C_FLAGS_INIT and this fails. Libwebsockets build fails with

error: implicit declaration of function 'wolfSSL_get_ex_new_index' is invalid in C99

and this function is defined only if HAVE_EX_DATA is defined. I also didn't find any occurrence of CMAKE_C_FLAGS_INIT in CMakeLists (latest sources).

Share

Re: Extending CMakeLists.txt to support libwebsockets

The problem was in toolchain file. It had CMAKE_C_FLAGS set to some value and CMAKE_C_FLAGS_INIT didn't work. After changing  CMAKE_C_FLAGS to

string(APPEND CMAKE_C_FLAGS_INIT " -DARM64=1 ...")

all works fine.

Share

Re: Extending CMakeLists.txt to support libwebsockets

still have problem getting wolfssl with libwebsockets working ... lws cannot find wolfSSL_X509_VERIFY_PARAM_set1_host during configuration and I have no idea why. Wolfssl is compiled this way:

cmake .. -DCMAKE_C_FLAGS_INIT="-DOPENSSL_EXTRA -DWOLFSSL_LIBWEBSOCKETS -DHAVE_EX_DATA -DOPENSSL_ALL -DHAVE_ALPN" -DNDK=${NDK_PATH} -DCMAKE_TOOLCHAIN_FILE=${PWD}/../../../../../../CMakeModules/cross-${s}-android.cmake -DWOLFSSL_CERTGEN=yes -DWOLFSSL_CERTREQ=yes -DWOLFSSL_CERTEXT=yes -DWOLFSSL_PKCS7=yes -DWOLFSSL_CRYPTOCB=yes -DWOLFSSL_AESCFB=yes -DWOLFSSL_KEYGEN=yes -DBUILD_SHARED_LIBS=0

But

~/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/x86_64-linux-android/bin/readelf -s build/wolfSSL/build_x86_64/libwolfssl.a | grep wolfSSL_X509_VERIFY_PARAM_set1_host

shows no export of wolfSSL_X509_VERIFY_PARAM_set1_host
But according to sources it is the only define required. Generated options.h has #define OPENSSL_EXTRA. What I'm missing?

Share

Re: Extending CMakeLists.txt to support libwebsockets

>  lws cannot find wolfSSL_X509_VERIFY_PARAM_set1_host

This is quite odd. The macro `OPENSSL_EXTRA` is the only define gating the definition. Maybe try with

-DWOLFSSL_OPENSSLEXTRA=yes

instead of using the CFLAG value.