Topic: Problems during Cmake build integration
Hi everyone,
first of all thanks for the extensive library - looks really promising and might be exactly suited for our usecase in the embedded space!
I understand that CMake isn't the primary build system for wolfSSL, however since it's the main build system generator together with make in our project, this would be my preferred integration into our existing infrastructure. I would like to have it both available to link against our cross-compiled NXP LPC microcontroller and for off-target unit testing in CI/CD pipelines or on development machines. We have rather minimal requirements, SHA and ECC is enough for our current needs but it's great to have a bigger set of features available if needed at some point.
I'm struggling a bit at the moment to integrate it within CMake (wolfSSL Release 5.8.0; Apr 24, 2025). Following the INSTALL file in the repo and [1], I've took an example user_settings template from the examples folder and reduced it to what I believe we would need to start. I created a simple wrapper CMakeLists.txt that lives outside of the wolfSSL sources and includes our project specific needs. When running the build, I get a bunch of redefine macro errors:
cd .../build/test/test/lib/wolfssl/wolfssl && /usr/sbin/cc -DBUILDING_WOLFSSL -DECC_SHAMIR -DECC_TIMING_RESISTANT -DGCM_TABLE_4BIT -DHAVE_AESGCM -DHAVE_CHACHA -DHAVE_CONFIG_H -DHAVE_DH_DEFAULT_PARAMS -DHAVE_ECC -DHAVE_ENCRYPT_THEN_MAC -DHAVE_EXTENDED_MASTER -DHAVE_FFDHE_2048 -DHAVE_HASHDRBG -DHAVE_HKDF -DHAVE_ONE_TIME_AUTH -DHAVE_POLY1305 -DHAVE_PTHREAD -DHAVE_SNI -DHAVE_SUPPORTED_CURVES -DHAVE_THREAD_LS -DHAVE_TLS_EXTENSIONS -DHAVE___UINT128_T -DNO_DES3 -DNO_DES3_TLS_SUITES -DNO_DSA -DNO_MD4 -DNO_PSK -DNO_RC4 -DTFM_ECC256 -DTFM_TIMING_RESISTANT -DWC_NO_ASYNC_THREADING -DWC_RSA_BLINDING -DWC_RSA_PSS -DWOLFSSL_BASE64_ENCODE -DWOLFSSL_IGNORE_FILE_WARN -DWOLFSSL_NO_SHAKE128 -DWOLFSSL_NO_SHAKE256 -DWOLFSSL_PSS_LONG_SALT -DWOLFSSL_SHA224 -DWOLFSSL_SHA3 -DWOLFSSL_SHA384 -DWOLFSSL_SHA512 -DWOLFSSL_SYS_CA_CERTS -DWOLFSSL_TLS13 -DWOLFSSL_USER_SETTINGS -DWOLFSSL_USE_ALIGN -DWOLFSSL_X86_64_BUILD -I.../lib/wolfssl/wolfssl -I.../build/test/test/lib/wolfssl/wolfssl -I.../lib/wolfssl -Wall -Wextra -Wno-unused -Werror -g -MD -MT lib/wolfssl/wolfssl/CMakeFiles/wolfssl.dir/wolfcrypt/src/sp_int.c.o -MF CMakeFiles/wolfssl.dir/wolfcrypt/src/sp_int.c.o.d -o CMakeFiles/wolfssl.dir/wolfcrypt/src/sp_int.c.o -c .../lib/wolfssl/wolfssl/wolfcrypt/src/sp_int.c
In file included from .../lib/wolfssl/wolfssl/wolfssl/wolfcrypt/settings.h:339,
from .../lib/wolfssl/wolfssl/wolfssl/wolfcrypt/types.h:34,
from .../lib/wolfssl/wolfssl/wolfssl/wolfcrypt/libwolfssl_sources.h:46,
from .../lib/wolfssl/wolfssl/wolfcrypt/src/hmac.c:23:
.../lib/wolfssl/user_settings.h:527:9: error: "NO_PSK" redefined [-Werror]
527 | #define NO_PSK
| ^~~~~~
<command-line>: note: this is the location of the previous definition
.../lib/wolfssl/user_settings.h:529:9: error: "NO_DSA" redefined [-Werror]
529 | #define NO_DSA
As the build errors occur already while compiling the wolfSSL library, I assume that my configuration might not be correct. I tried to search this forum and other sources for additional input but failed to resolve the issue on my own. Could you please provide some pointers or recommendations on what I might be missing? As I've got an error uploading files to this post, both are provided via pastebin in [2] and [3] instead below.
Thanks in advance,
Johannes
[1] - https://www.wolfssl.com/how-do-i-manage … f-wolfssl/
[2] - https://pastebin.com/sADS3THb
[3] - https://pastebin.com/GC6JsJpU
PS: Directory structure looks currently like this:
.../lib/wolfssl % >> ls -lah
total 36K
drwxr-xr-x 3 dev dev 4.0K May 20 07:37 .
drwxr-xr-x 13 dev dev 4.0K May 14 08:43 ..
-rw-r--r-- 1 dev dev 369 May 20 07:37 CMakeLists.txt
-rw-r--r-- 1 dev dev 14K May 20 07:37 user_settings.h
drwxr-xr-x 29 dev dev 4.0K May 14 08:52 wolfssl
-rw-r--r-- 1 dev dev 356 May 19 07:30 wolfssl.cmake
The woflssl.cmake just pulls in the wolfssl project sources with FetchContent. The CMakeLists.txt is read during the configuration/build and included via the regular:
target_link_libraries(${PROJECT_NAME} PRIVATE wolfssl)
Tooling versions are:
% >> gcc --version
gcc (GCC) 14.2.1 20240910
% >> cmake --version
cmake version 3.31.5
% >> make --version
GNU Make 4.4.1