Skip to content

Build fixes on mbedtls and mqttc for CMake#3444

Open
fdcavalcanti wants to merge 2 commits intoapache:masterfrom
fdcavalcanti:bugfix/apps-path
Open

Build fixes on mbedtls and mqttc for CMake#3444
fdcavalcanti wants to merge 2 commits intoapache:masterfrom
fdcavalcanti:bugfix/apps-path

Conversation

@fdcavalcanti
Copy link
Copy Markdown
Contributor

Summary

  • crypto/mbedtls: expose include paths as public

Expose include paths as public when using CMake.

  • netutils/mqttc: fix patch and add mbedtls dependency

Add mbedtls dependecy and fix patch path.

Apps mbedtls no longer appends its include directories to the global nuttx target (NUTTX_INCLUDE_DIRECTORIES / NUTTX_CXX_INCLUDE_DIRECTORIES). That global injection caused arch/vendor code (e.g. Espressif tf-psa-crypto) to pick up headers from nuttx-apps/crypto/mbedtls/mbedtls/include, which mixed two incompatible Mbed TLS trees and led to PSA/config include errors.

The post-FetchContent patch step used $(MQTTC_DIR) inside sh -c, which the shell treats as command substitution, not a CMake path. Replaced with a direct patch -d ${MQTTC_DIR} -p1 -i … invocation.
With mbedtls includes no longer global, MQTT-C with mbedtls wires nuttx_add_dependencies(TARGET mqttc DEPENDS mbedtls) when both CONFIG_NETUTILS_MQTTC_WITH_MBEDTLS and CONFIG_CRYPTO_MBEDTLS are set, and mqttc_mbedtls_pub lists mbedtls in DEPENDS so the example compiles against the same headers as the library.

This fixes build issues for Espressif devices whenever mbedtls was added (affecting CMake support only).

Impact

Impact on user: No.

Impact on build: Make builds are unaffected.
Anything that included <mbedtls/...> only because of those global includes, and does not get headers via:

  • DEPENDS mbedtls / nuttx_add_dependencies(… mbedtls), or
  • its own INCLUDE_DIRECTORIES / target_include_directories,
    could fail to compile until it gains an explicit dependency or include path. That is not vendor-specific; it depends on how each app’s CMakeLists.txt was written.

Impact on hardware: No.

Impact on documentation: No.

Impact on security: No.

Impact on compatibility: No.

Testing

Building

CMake build for esp32c3-devkit:wifi.
Append the following:

CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y
CONFIG_DEBUG_FEATURES=y
CONFIG_CRYPTO_MBEDTLS=y
CONFIG_MBEDTLS_APPS=y
CONFIG_MBEDTLS_APP_BENCHMARK=y
CONFIG_MBEDTLS_APP_SELFTEST=y
CONFIG_MBEDTLS_SELF_TEST=y
CONFIG_MBEDTLS_VERSION="3.6.2"
CONFIG_NETUTILS_MQTTC=y
CONFIG_NETUTILS_MQTTC_EXAMPLE=y
CONFIG_NETUTILS_MQTTC_WITH_MBEDTLS=y
CONFIG_NETUTILS_MQTTC_VERSION="1.1.5"
CONFIG_DEV_URANDOM=y

Results

CMake build would fail for this scenario, but works after the changes.

Add mbedtls dependecy and fix patch path.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
@fdcavalcanti fdcavalcanti changed the title Bugfix/apps path Build fixes on mbedtls and mqttc for CMake Apr 1, 2026
Copy link
Copy Markdown
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @fdcavalcanti :-)

linguini1
linguini1 previously approved these changes Apr 1, 2026
@fdcavalcanti
Copy link
Copy Markdown
Contributor Author

I see CI is complaining about the change, I'll investigate.

@simbit18 simbit18 marked this pull request as draft April 2, 2026 12:32
@simbit18
Copy link
Copy Markdown
Contributor

simbit18 commented Apr 2, 2026

@fdcavalcanti marked as a draft

Copy link
Copy Markdown
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to note build fixes required :-)

Expose include paths as public when using CMake.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
@fdcavalcanti fdcavalcanti marked this pull request as ready for review April 3, 2026 00:34
# Overlay mbedtls_config.h cannot be in the same nuttx_export_header() as
# ${MBEDTLS_DIR}/include (duplicate path). Alt headers need no export; INCDIR
# supplies them for this library only.
file(CREATE_LINK ${CMAKE_CURRENT_LIST_DIR}/include/mbedtls/mbedtls_config.h
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fdcavalcanti, Perhaps it would be better to use function

nuttx_create_symlink

https://github.com/apache/nuttx/blob/master/cmake/nuttx_create_symlink.cmake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants