mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'tools/fix_cmake_variables_propagation' into 'master'
tools: Fix cmake variable propagation Closes IDFGH-7212 and IDFGH-7292 See merge request espressif/esp-idf!17983
This commit is contained in:
commit
3bf6e06a80
@ -55,3 +55,18 @@ instead of::
|
|||||||
set(EXTRA_COMPONENT_DIRS "${EXTRA_COMPONENT_DIRS} path3")
|
set(EXTRA_COMPONENT_DIRS "${EXTRA_COMPONENT_DIRS} path3")
|
||||||
|
|
||||||
Defining these variables as CMake lists is compatible with previous IDF versions.
|
Defining these variables as CMake lists is compatible with previous IDF versions.
|
||||||
|
|
||||||
|
Update usage of target_link_libraries with project_elf
|
||||||
|
------------------------------------------------------
|
||||||
|
|
||||||
|
ESP-IDF v5.0 fixes issues with CMake variable propagation for components, which caused among others compiler flags and defines applied to one component to be applied to every component in the project.
|
||||||
|
|
||||||
|
As a side effect of this ESP-IDF user projects from ESP-IDF v5.0 onwards using ``target_link_libraries`` with ``project_elf`` explicitly and custom CMake projects must specify ``PRIVATE``, ``PUBLIC`` or ``INTERFACE`` arguments. This is a breaking change and is not backwards compatible with previous ESP-IDF versions.
|
||||||
|
|
||||||
|
For example::
|
||||||
|
|
||||||
|
target_link_libraries(${project_elf} PRIVATE "-Wl,--wrap=esp_panic_handler")
|
||||||
|
|
||||||
|
instead of::
|
||||||
|
|
||||||
|
target_link_libraries(${project_elf} "-Wl,--wrap=esp_panic_handler")
|
||||||
|
@ -473,17 +473,17 @@ macro(project project_name)
|
|||||||
add_dependencies(${project_elf} _project_elf_src)
|
add_dependencies(${project_elf} _project_elf_src)
|
||||||
|
|
||||||
if(__PROJECT_GROUP_LINK_COMPONENTS)
|
if(__PROJECT_GROUP_LINK_COMPONENTS)
|
||||||
target_link_libraries(${project_elf} "-Wl,--start-group")
|
target_link_libraries(${project_elf} PRIVATE "-Wl,--start-group")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(test_components)
|
if(test_components)
|
||||||
target_link_libraries(${project_elf} "-Wl,--whole-archive")
|
target_link_libraries(${project_elf} PRIVATE "-Wl,--whole-archive")
|
||||||
foreach(test_component ${test_components})
|
foreach(test_component ${test_components})
|
||||||
if(TARGET ${test_component})
|
if(TARGET ${test_component})
|
||||||
target_link_libraries(${project_elf} ${test_component})
|
target_link_libraries(${project_elf} PRIVATE ${test_component})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
target_link_libraries(${project_elf} "-Wl,--no-whole-archive")
|
target_link_libraries(${project_elf} PRIVATE "-Wl,--no-whole-archive")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
idf_build_get_property(build_components BUILD_COMPONENT_ALIASES)
|
idf_build_get_property(build_components BUILD_COMPONENT_ALIASES)
|
||||||
@ -496,9 +496,12 @@ macro(project project_name)
|
|||||||
__component_get_property(whole_archive ${build_component_target} WHOLE_ARCHIVE)
|
__component_get_property(whole_archive ${build_component_target} WHOLE_ARCHIVE)
|
||||||
if(whole_archive)
|
if(whole_archive)
|
||||||
message(STATUS "Component ${build_component} will be linked with -Wl,--whole-archive")
|
message(STATUS "Component ${build_component} will be linked with -Wl,--whole-archive")
|
||||||
target_link_libraries(${project_elf} "-Wl,--whole-archive" ${build_component} "-Wl,--no-whole-archive")
|
target_link_libraries(${project_elf} PRIVATE
|
||||||
|
"-Wl,--whole-archive"
|
||||||
|
${build_component}
|
||||||
|
"-Wl,--no-whole-archive")
|
||||||
else()
|
else()
|
||||||
target_link_libraries(${project_elf} ${build_component})
|
target_link_libraries(${project_elf} PRIVATE ${build_component})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
@ -507,7 +510,7 @@ macro(project project_name)
|
|||||||
set(mapfile "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.map")
|
set(mapfile "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.map")
|
||||||
set(idf_target "${IDF_TARGET}")
|
set(idf_target "${IDF_TARGET}")
|
||||||
string(TOUPPER ${idf_target} idf_target)
|
string(TOUPPER ${idf_target} idf_target)
|
||||||
target_link_libraries(${project_elf} "-Wl,--cref" "-Wl,--defsym=IDF_TARGET_${idf_target}=0"
|
target_link_libraries(${project_elf} PRIVATE "-Wl,--cref" "-Wl,--defsym=IDF_TARGET_${idf_target}=0"
|
||||||
"-Wl,--Map=\"${mapfile}\"")
|
"-Wl,--Map=\"${mapfile}\"")
|
||||||
unset(idf_target)
|
unset(idf_target)
|
||||||
endif()
|
endif()
|
||||||
|
@ -4,6 +4,6 @@ if((IDF_TARGET STREQUAL "esp32s2") OR (IDF_TARGET STREQUAL "esp32c3"))
|
|||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
project(test_memprot)
|
project(test_memprot)
|
||||||
|
|
||||||
target_link_libraries(${project_elf} "-Wl,--wrap=esp_panic_handler")
|
target_link_libraries(${project_elf} PRIVATE "-Wl,--wrap=esp_panic_handler")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user