The AFR::demo_mqtt target defines the demo source files, header files, and dependencies required to run the MQTT demo application. If you’re writing your own application and not using the MQTT demo source files, then you don’t need to link to this target.
If you are creating your own application, then you will need to add dependencies to your targets as required. For example, if your application uses the MQTT library, then you will need to add a dependency on the AFR::mqtt target.
if( SYSTEM_Init() == pdPASS )
{
/* A simple example to demonstrate key and certificate provisioning in
* microcontroller flash using PKCS#11 interface. This should be replaced
* by production ready key provisioning mechanism. */
vDevModeKeyProvisioning();
So what’s the best way to add the correct dependencies? Thanks!
The code you referenced seems to be from the demo. If this is the case, you will need to add the dependencies required by the demo. You can do this with your current code: target_link_libraries(esp32_app PRIVATE AFR::demo_mqtt)
Here is some additional information if you’re not planning on using the demo.
The code related to AFR is organized into a number of different targets. Each target represents a grouping of code (typically a library) and defines things required for building such as source code, include paths, compiler options, and a list of other targets that it depends on. As you have seen previously, the library targets are identified by names such as AFR::mqtt.
Dependencies added with target_link_libraries are transitive. For example, if you have
target_link_libraries(A PRIVATE AFR::ota), then you can also use mqtt in A because OTA depends on mqtt.