!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
26 lines
668 B
CMake
26 lines
668 B
CMake
set(COMPONENT_SRCS "main.cpp")
|
|
set(COMPONENT_ADD_INCLUDEDIRS ".")
|
|
|
|
set(COMPONENT_EMBED_TXTFILES "sample.xml")
|
|
|
|
register_component()
|
|
|
|
# Build static library, do not build test executables
|
|
option(BUILD_SHARED_LIBS OFF)
|
|
option(BUILD_TESTING OFF)
|
|
|
|
# Unfortunately the library performs install and export. Would
|
|
# have been nice if devs made that an option like BUILD_SHARED_LIBS
|
|
# and BUILD_TESTING. Override install() and export() to do nothing
|
|
# instead.
|
|
function(install)
|
|
endfunction()
|
|
|
|
function(export)
|
|
endfunction()
|
|
|
|
# Import tinyxml2 targets
|
|
add_subdirectory(lib/tinyxml2)
|
|
|
|
# Link tinyxml2 to main component
|
|
target_link_libraries(${COMPONENT_LIB} PUBLIC tinyxml2)
|