I've looked at the site here and on the internet, and even on cmake.org - and didn't find this but wanted to post it here in case it could be helpful.
Here's an example cmakelists.txt file:
idf_component_register(SRCS "main.c"
INCLUDE_DIRS ".")
- Import the library, specifying a target name and the library path.
The private dependencies of the library is also specified.
add_prebuilt_library(prebuilt "libprebuilt.a" PRIV_REQUIRES spi_flash app_update log)
main
calls a function from the library, so link it tomain
target_link_libraries(${COMPONENT_LIB} PRIVATE prebuilt)
That works. Of course, in the PRIV_REQUIRES need to be all of the component modules that are used by the static prebuilt lib.
For more of a real-world example - please look here: https://github.com/espressif/esp-idf/tree/release/v4.0/examples/build_system/cmake/import_prebuilt
Credit goes to the folks at espressif - when I was using a cmake editor even the auto-complete didn't find add_prebuilt...
Hope some find this helpful as it didn't take me long to fall down this cmake syntax rabbit hole.
Regards, John W.