Merge branch 'bugfix/even_more_cmake_fixes' into 'master'

Even more CMake fixes

See merge request idf/esp-idf!5097
This commit is contained in:
Angus Gratton
2019-06-12 08:08:04 +08:00
29 changed files with 240 additions and 230 deletions

View File

@@ -31,4 +31,4 @@ register_component()
# disable --coverage for this component, as it is used as transport
# for gcov
target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-profile-arcs" "-fno-test-coverage")
target_link_libraries(${COMPONENT_LIB} gcov ${LIBC} ${LIBM} gcc)
target_link_libraries(${COMPONENT_LIB} PUBLIC gcov ${LIBC} ${LIBM} gcc)

View File

@@ -8,7 +8,7 @@ register_component()
# esp_app_desc structure is added as an undefined symbol because otherwise the
# linker will ignore this structure as it has no other files depending on it.
target_link_libraries(${COMPONENT_LIB} "-u esp_app_desc")
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_app_desc")
# cut PROJECT_VER and PROJECT_NAME to required 32 characters.
idf_build_get_property(project_ver PROJECT_VER)

View File

@@ -7,4 +7,4 @@ idf_build_get_property(target IDF_TARGET)
set(scripts "${target}.bootloader.ld"
"${target}.bootloader.rom.ld")
target_linker_script(${COMPONENT_LIB} "${scripts}")
target_linker_script(${COMPONENT_LIB} INTERFACE "${scripts}")

View File

@@ -9,8 +9,8 @@ set(COMPONENT_SRCS "src/bootloader_clock.c"
if(BOOTLOADER_BUILD)
set(COMPONENT_ADD_INCLUDEDIRS "include include_bootloader")
set(COMPONENT_REQUIRES spi_flash soc) #unfortunately the header directly uses SOC registers
set(COMPONENT_PRIV_REQUIRES micro-ecc efuse)
set(COMPONENT_REQUIRES soc) #unfortunately the header directly uses SOC registers
set(COMPONENT_PRIV_REQUIRES micro-ecc spi_flash efuse)
list(APPEND COMPONENT_SRCS "src/bootloader_init.c"
"src/${IDF_TARGET}/bootloader_sha.c"
"src/${IDF_TARGET}/flash_encrypt.c"
@@ -55,8 +55,8 @@ else()
"src/idf/secure_boot_signatures.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_PRIV_INCLUDEDIRS "include_bootloader")
set(COMPONENT_REQUIRES mbedtls soc) #unfortunately the header directly uses SOC registers
set(COMPONENT_PRIV_REQUIRES spi_flash efuse)
set(COMPONENT_REQUIRES soc) #unfortunately the header directly uses SOC registers
set(COMPONENT_PRIV_REQUIRES spi_flash mbedtls efuse)
endif()
register_component()

View File

@@ -295,6 +295,6 @@ if(CONFIG_BT_ENABLED)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough -Wno-unused-const-variable)
endif()
target_link_libraries(${COMPONENT_LIB} "-L${CMAKE_CURRENT_LIST_DIR}/lib")
target_link_libraries(${COMPONENT_LIB} btdm_app)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-L${CMAKE_CURRENT_LIST_DIR}/lib")
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
endif()

View File

@@ -2,9 +2,9 @@ set(COMPONENT_SRCS "cxx_exception_stubs.cpp"
"cxx_guards.cpp")
register_component()
target_link_libraries(${COMPONENT_LIB} stdc++ gcc)
target_link_libraries(${COMPONENT_LIB} "-u __cxa_guard_dummy")
target_link_libraries(${COMPONENT_LIB} PUBLIC stdc++ gcc)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __cxa_guard_dummy")
if(NOT CONFIG_COMPILER_CXX_EXCEPTIONS)
target_link_libraries(${COMPONENT_LIB} "-u __cxx_fatal_exception")
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __cxx_fatal_exception")
endif()

View File

@@ -4,7 +4,7 @@ if(BOOTLOADER_BUILD)
# For bootloader, all we need from esp32 is headers
set(COMPONENT_ADD_INCLUDEDIRS include)
register_component()
target_linker_script(${COMPONENT_LIB} "ld/esp32.peripherals.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32.peripherals.ld")
else()
# Regular app build
@@ -34,40 +34,41 @@ else()
"task_wdt.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_REQUIRES app_update driver esp_event efuse pthread soc) #unfortunately rom/uart uses SOC registers directly
set(COMPONENT_REQUIRES driver esp_event efuse soc) #unfortunately rom/uart uses SOC registers directly
# driver is a public requirement because esp_sleep.h uses gpio_num_t & touch_pad_t
# app_update is added here because cpu_start.c uses esp_ota_get_app_description() function.
set(COMPONENT_PRIV_REQUIRES
app_trace app_update bootloader_support log mbedtls nvs_flash
app_trace app_update bootloader_support log mbedtls nvs_flash pthread
smartconfig_ack spi_flash vfs wpa_supplicant espcoredump esp_common esp_wifi)
set(COMPONENT_ADD_LDFRAGMENTS linker.lf ld/esp32_fragments.lf)
register_component()
target_linker_script(${COMPONENT_LIB} "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
# Rely on user code to define app_main
target_link_libraries(${COMPONENT_LIB} "-u app_main")
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u app_main")
if(CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY)
# This has to be linked before esp32.project.ld
target_linker_script(${COMPONENT_LIB} "ld/esp32.extram.bss.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32.extram.bss.ld")
endif()
# Process the template file through the linker script generation mechanism, and use the output for linking the
# final binary
target_linker_script(${COMPONENT_LIB} "${CMAKE_CURRENT_LIST_DIR}/ld/esp32.project.ld.in" PROCESS)
target_linker_script(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_LIST_DIR}/ld/esp32.project.ld.in"
PROCESS "${CMAKE_CURRENT_BINARY_DIR}/ld/esp32.project.ld")
target_linker_script(${COMPONENT_LIB} "ld/esp32.peripherals.ld")
target_link_libraries(${COMPONENT_LIB} gcc)
target_link_libraries(${COMPONENT_LIB} "-u call_user_start_cpu0")
target_linker_script(${COMPONENT_LIB} INTERFACE "ld/esp32.peripherals.ld")
target_link_libraries(${COMPONENT_LIB} PUBLIC gcc)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u call_user_start_cpu0")
#ld_include_panic_highint_hdl is added as an undefined symbol because otherwise the
#linker will ignore panic_highint_hdl.S as it has no other files depending on any
#symbols in it.
target_link_libraries(${COMPONENT_LIB} "-u ld_include_panic_highint_hdl")
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ld_include_panic_highint_hdl")
idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER)
get_filename_component(config_dir ${sdkconfig_header} DIRECTORY)
@@ -95,6 +96,6 @@ else()
# To handle some corner cases, the same flag is set in project_include.cmake
target_compile_options(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-issue)
# also, make sure we link with this option so correct toolchain libs are pulled in
target_link_libraries(${COMPONENT_LIB} -mfix-esp32-psram-cache-issue)
target_link_libraries(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-issue)
endif()
endif()

View File

@@ -9,7 +9,7 @@ if(BOOTLOADER_BUILD)
"esp32/ld/esp32.rom.newlib-funcs.ld"
"esp32/ld/esp32.rom.libgcc.ld"
)
target_linker_script(${COMPONENT_LIB} "${scripts}")
target_linker_script(${COMPONENT_LIB} INTERFACE "${scripts}")
else()
# Regular app build
set(COMPONENT_SRCS "esp_rom.c")
@@ -23,21 +23,21 @@ else()
"esp32/ld/esp32.rom.syscalls.ld"
"esp32/ld/esp32.rom.newlib-data.ld"
)
target_linker_script(${COMPONENT_LIB} "${scripts}")
target_linker_script(${COMPONENT_LIB} INTERFACE "${scripts}")
if(NOT CONFIG_SPIRAM_CACHE_WORKAROUND)
target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.newlib-funcs.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "esp32/ld/esp32.rom.newlib-funcs.ld")
endif()
if(CONFIG_NEWLIB_NANO_FORMAT)
target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.newlib-nano.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "esp32/ld/esp32.rom.newlib-nano.ld")
endif()
if(NOT GCC_NOT_5_2_0)
target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.newlib-locale.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "esp32/ld/esp32.rom.newlib-locale.ld")
endif()
if(NOT CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)
target_linker_script(${COMPONENT_LIB} "esp32/ld/esp32.rom.spiflash.ld")
target_linker_script(${COMPONENT_LIB} INTERFACE "esp32/ld/esp32.rom.spiflash.ld")
endif()
endif()

View File

@@ -8,22 +8,21 @@ set(COMPONENT_SRCS
"src/wifi_init.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_PRIV_INCLUDEDIRS)
set(COMPONENT_REQUIRES wpa_supplicant smartconfig_ack)
set(COMPONENT_PRIV_REQUIRES "nvs_flash")
set(COMPONENT_PRIV_REQUIRES wpa_supplicant nvs_flash)
if(NOT CONFIG_ESP32_NO_BLOBS)
set(COMPONENT_ADD_LDFRAGMENTS "linker.lf")
endif()
register_component()
target_link_libraries(${COMPONENT_LIB} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}")
target_link_libraries(${COMPONENT_LIB} PUBLIC "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}")
if(NOT CONFIG_ESP32_NO_BLOBS)
set(blobs coexist core espnow mesh net80211 phy pp rtc smartconfig wpa2 wpa wps)
foreach(blob ${blobs})
add_library(${blob} STATIC IMPORTED)
set_property(TARGET ${blob} PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/lib_${IDF_TARGET}/lib${blob}.a)
target_link_libraries(${COMPONENT_LIB} ${blob})
target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob})
foreach(_blob ${blobs})
if(NOT _blob STREQUAL ${blob})

View File

@@ -25,7 +25,7 @@ set(COMPONENT_ADD_LDFRAGMENTS linker.lf)
register_component()
target_link_libraries(${COMPONENT_LIB} "-Wl,--undefined=uxTopUsedPriority")
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--undefined=uxTopUsedPriority")
set_source_files_properties(
tasks.c

View File

@@ -32,7 +32,7 @@ if(CONFIG_HEAP_TRACING)
heap_caps_realloc_default)
foreach(wrap ${WRAP_FUNCTIONS})
target_link_libraries(${COMPONENT_LIB} "-Wl,--wrap=${wrap}")
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=${wrap}")
endforeach()
endif()

View File

@@ -126,7 +126,7 @@ endif()
set(COMPONENT_ADD_INCLUDEDIRS ${SRC}/include port_include)
set(COMPONENT_PRIV_INCLUDEDIRS ${SRC}/include/sodium port_include/sodium port)
set(COMPONENT_REQUIRES mbedtls vfs)
set(COMPONENT_REQUIRES mbedtls)
register_component()
target_compile_definitions(${COMPONENT_LIB} PRIVATE

View File

@@ -2,8 +2,6 @@ set(COMPONENT_ADD_INCLUDEDIRS "port/include" "mbedtls/include")
set(COMPONENT_SRCS "mbedtls.c")
set(COMPONENT_REQUIRES lwip)
set(MBEDTLS_PRIV_REQUIRES ${IDF_COMPONENT_REQUIRES_COMMON} soc)
register_component()
# Only build mbedtls libraries
@@ -96,9 +94,4 @@ foreach(target ${mbedtls_targets})
endforeach()
# Link mbedtls libraries to component library
target_link_libraries(${COMPONENT_LIB} ${mbedtls_targets})
# Catch usage of deprecated mbedTLS functions when building tests
if(mbedtls_test IN_LIST BUILD_TEST_COMPONENTS)
add_definitions(-DMBEDTLS_DEPRECATED_WARNING)
endif()
target_link_libraries(${COMPONENT_LIB} INTERFACE ${mbedtls_targets})

View File

@@ -4,3 +4,9 @@ set(COMPONENT_ADD_INCLUDEDIRS ".")
set(COMPONENT_REQUIRES unity test_utils mbedtls)
register_component()
idf_component_get_property(mbedtls mbedtls COMPONENT_LIB)
target_compile_definitions(${mbedtls} PUBLIC "-DMBEDTLS_DEPRECATED_WARNING")
target_compile_definitions(mbedtls PUBLIC "-DMBEDTLS_DEPRECATED_WARNING")
target_compile_definitions(mbedcrypto PUBLIC "-DMBEDTLS_DEPRECATED_WARNING")
target_compile_definitions(mbedx509 PUBLIC "-DMBEDTLS_DEPRECATED_WARNING")

View File

@@ -42,8 +42,8 @@ list(APPEND COMPONENT_ADD_LDFRAGMENTS newlib.lf)
register_component()
if (LIB_PATH)
target_link_libraries(${COMPONENT_LIB} "-L ${LIB_PATH}")
if(LIB_PATH)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-L ${LIB_PATH}")
endif()
if(GCC_NOT_5_2_0)
@@ -51,13 +51,13 @@ if(GCC_NOT_5_2_0)
add_library(extra INTERFACE)
idf_component_get_property(newlib newlib COMPONENT_LIB)
target_link_libraries(extra INTERFACE ${LIBC} ${LIBM} gcc "$<TARGET_FILE:${newlib}>")
target_link_libraries(${COMPONENT_LIB} extra)
target_link_libraries(${COMPONENT_LIB} PUBLIC extra)
else()
target_link_libraries(${COMPONENT_LIB} ${LIBC} ${LIBM} gcc)
target_link_libraries(${COMPONENT_LIB} PUBLIC ${LIBC} ${LIBM} gcc)
endif()
set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
if(EXTRA_LINK_FLAGS)
target_link_libraries(${COMPONENT_LIB} "${EXTRA_LINK_FLAGS}")
target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}")
endif()

View File

@@ -12,8 +12,7 @@ set(COMPONENT_SRCS "src/common/protocomm.c"
"src/transports/protocomm_console.c"
"src/transports/protocomm_httpd.c")
set(COMPONENT_REQUIRES protobuf-c bt)
set(COMPONENT_PRIV_REQUIRES mbedtls console esp_http_server)
set(COMPONENT_PRIV_REQUIRES protobuf-c mbedtls console esp_http_server bt)
if(CONFIG_BT_ENABLED)
if(CONFIG_BT_BLUEDROID_ENABLED)

View File

@@ -9,8 +9,7 @@ else()
"flash_ops.c"
"partition.c"
"spi_flash_rom_patch.c")
set(COMPONENT_REQUIRES app_update)
set(COMPONENT_PRIV_REQUIRES bootloader_support soc)
set(COMPONENT_PRIV_REQUIRES bootloader_support app_update soc)
endif()
set(COMPONENT_ADD_INCLUDEDIRS include)

View File

@@ -61,7 +61,7 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs)
add_dependencies(${COMPONENT_LIB} ${app_name}_artifacts)
target_linker_script(${COMPONENT_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${app_name}/${app_name}.ld)
target_linker_script(${COMPONENT_LIB} INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/${app_name}/${app_name}.ld)
target_add_binary_data(${COMPONENT_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${app_name}/${app_name}.bin BINARY)
endif()
endfunction()

View File

@@ -6,4 +6,4 @@ register_component()
# Some newlib syscalls are implemented in vfs.c, make sure these are always
# seen by the linker
target_link_libraries(${COMPONENT_LIB} "-u vfs_include_syscalls_impl")
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u vfs_include_syscalls_impl")

View File

@@ -7,4 +7,4 @@ set(COMPONENT_PRIV_REQUIRES soc)
register_component()
target_link_libraries(${COMPONENT_LIB} "${CMAKE_CURRENT_SOURCE_DIR}/${IDF_TARGET}/libhal.a")
target_link_libraries(${COMPONENT_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${IDF_TARGET}/libhal.a")