CMakeLists.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_ipc.c"
  13. "esp_err.c"
  14. "freertos_hooks.c"
  15. "int_wdt.c"
  16. "panic.c"
  17. "esp_system.c"
  18. "startup.c"
  19. "system_time.c"
  20. "stack_check.c"
  21. "task_wdt.c"
  22. "ubsan.c"
  23. "xt_wdt.c"
  24. "debug_stubs.c")
  25. if(CONFIG_ESP_SYSTEM_USE_EH_FRAME)
  26. list(APPEND srcs "eh_frame_parser.c")
  27. endif()
  28. idf_component_register(SRCS "${srcs}"
  29. INCLUDE_DIRS include
  30. PRIV_REQUIRES spi_flash esp_timer
  31. # [refactor-todo] requirements due to init code,
  32. # should be removable once using component init functions
  33. # link-time registration is used.
  34. # [refactor-todo] requires "driver" for headers:
  35. # - spi_common_internal.h
  36. pthread bootloader_support efuse driver
  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")
  61. # [refactor-todo] requirements due to init code, should be removable
  62. # once link-time registration of component init functions is used.
  63. if(CONFIG_APPTRACE_ENABLE)
  64. idf_component_optional_requires(PRIVATE app_trace)
  65. endif()
  66. if(CONFIG_ESP_COREDUMP_ENABLE)
  67. idf_component_optional_requires(PRIVATE espcoredump)
  68. endif()
  69. # [refactor-todo] requirement from the panic handler,
  70. # need to introduce panic "event" concept to remove this dependency (IDF-2194)
  71. idf_component_optional_requires(PRIVATE esp_gdbstub)
  72. idf_component_optional_requires(PRIVATE esp_app_format)
  73. if(CONFIG_PM_ENABLE)
  74. idf_component_optional_requires(PRIVATE pm)
  75. endif()
  76. if(CONFIG_VFS_SUPPORT_IO)
  77. idf_component_optional_requires(PRIVATE vfs)
  78. endif()
  79. if(CONFIG_SW_COEXIST_ENABLE OR CONFIG_EXTERNAL_COEX_ENABLE)
  80. idf_component_optional_requires(PRIVATE esp_wifi)
  81. endif()
  82. if(NOT BOOTLOADER_BUILD)
  83. if(CONFIG_SPIRAM)
  84. idf_component_optional_requires(PRIVATE esp_psram)
  85. endif()
  86. endif()
  87. target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")