mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
3882e48e8a
!4452 used setting LINK_LIBRARIES and INTERFACE_LINK_LIBRARIES to link components built under ESP-IDF build system. However, LINK_LIBRARIES does not produce behavior same as linking PRIVATE. This MR uses the new signature for target_link_libraries directly instead. This also moves setting dependencies during component registration rather than after all components have been processed. The consequence is that internally, components have to use the new signature form as well. This does not affect linking the components to external targets, such as with idf_as_lib example. This only affects linking additional libraries to ESP-IDF libraries outside component processing (after idf_build_process), which is not even possible for CMake<v3.13 as target_link_libraries is not valid for targets not created in current directory. See https://cmake.org/cmake/help/v3.13/policy/CMP0079.html#policy:CMP0079 |
||
---|---|---|
.. | ||
main | ||
CMakeLists.txt | ||
partitions_example.csv | ||
README.md | ||
sdkconfig.defaults |
Import Third-Party CMake Library Example
This example demonstrates how to import third-party CMake libraries.
Example Flow
tinyxml2 is a
a small C++ XML parser. It is imported, without modification, for use in the project's main
component (see the main
component's CMakeLists.txt). To demonstrate the library being used, a sample XML is embedded into the project.
This sample XML is then read and parsed later on using tinyxml2
.
Output
I (317) example: Setting up...
I (317) example: Copying sample XML to filesystem...
I (647) example: Reading XML file
I (657) example: Read XML data:
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
I (667) example: Parsed XML data:
To: Tove
From: Jani
Heading: Reminder
Body: Don't forget me this weekend!
I (677) example: Example end
There is a discussion on importing third-party CMake libraries in the programming guide under API Guides
-> Build System (CMake)
-> Using Third-Party CMake Projects with Components