CMakeLists.txt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. idf_build_get_property(target IDF_TARGET)
  2. set(srcs "esp_err.c")
  3. if(CONFIG_IDF_ENV_FPGA)
  4. list(APPEND srcs "fpga_overrides.c")
  5. endif()
  6. if(BOOTLOADER_BUILD)
  7. # "_esp_error_check_failed()" requires spi_flash module
  8. # Bootloader relies on some Kconfig options defined in esp_system.
  9. idf_component_register(SRCS "${srcs}" REQUIRES spi_flash)
  10. else()
  11. list(APPEND srcs "crosscore_int.c"
  12. "esp_err.c"
  13. "freertos_hooks.c"
  14. "int_wdt.c"
  15. "panic.c"
  16. "esp_system.c"
  17. "startup.c"
  18. "system_time.c"
  19. "stack_check.c"
  20. "task_wdt.c"
  21. "ubsan.c"
  22. "xt_wdt.c")
  23. if(NOT (${target} STREQUAL "esp32c3") AND NOT (${target} STREQUAL "esp32h2"))
  24. list(APPEND srcs "dbg_stubs.c")
  25. endif()
  26. if(CONFIG_ESP_SYSTEM_USE_EH_FRAME)
  27. list(APPEND srcs "eh_frame_parser.c")
  28. endif()
  29. idf_component_register(SRCS "${srcs}"
  30. INCLUDE_DIRS include
  31. PRIV_REQUIRES spi_flash
  32. # [refactor-todo] requirements due to init code,
  33. # should be removable once using component init functions
  34. # link-time registration is used.
  35. esp_pm app_update nvs_flash pthread app_trace esp_gdbstub
  36. espcoredump esp_phy efuse esp_ipc
  37. LDFRAGMENTS "linker.lf" "app.lf")
  38. add_subdirectory(port)
  39. # After system initialization, `start_app` (and its other cores variant) is called.
  40. # This is provided by the user or from another component. Since we can't establish
  41. # dependency on what we don't know, force linker to not drop the symbol regardless
  42. # of link line order.
  43. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app")
  44. if(NOT CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE)
  45. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app_other_cores")
  46. endif()
  47. # Disable stack protection in files which are involved in initialization of that feature
  48. set_source_files_properties(
  49. "startup.c" "stack_check.c"
  50. PROPERTIES COMPILE_FLAGS
  51. -fno-stack-protector)
  52. include(${CMAKE_CURRENT_LIST_DIR}/ld/ld.cmake)
  53. endif()
  54. if(CONFIG_IDF_ENV_FPGA)
  55. # Forces the linker to include fpga stubs from this component
  56. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_common_include_fpga_overrides")
  57. endif()
  58. # Force linking UBSAN hooks. If UBSAN is not enabled, the hooks will ultimately be removed
  59. # due to -ffunction-sections -Wl,--gc-sections options.
  60. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __ubsan_include")