CMakeLists.txt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # For more information about build system see
  2. # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
  3. # The following five lines of boilerplate have to be in your project's
  4. # CMakeLists in this exact order for cmake to work correctly
  5. cmake_minimum_required(VERSION 3.16)
  6. include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  7. # As this G0 example is not runnable as-is, the map file generated won't some important
  8. # sections. Thus, in order to prevent IDF from generating a map file at all, specify
  9. # null device as the destination file.
  10. if(WIN32)
  11. idf_build_set_property(LINK_OPTIONS "-Wl,--Map=NUL" APPEND)
  12. else()
  13. idf_build_set_property(LINK_OPTIONS "-Wl,--Map=/dev/null" APPEND)
  14. endif()
  15. # Force this project to use only G0 components
  16. set(all_g0_components esp_rom soc hal esp_common main) # also <arch>, i.e. xtensa or riscv, will be added below
  17. set(COMPONENTS ${all_g0_components})
  18. # By default, common components include some G1+ components. Override common components to only have G0 ones
  19. idf_build_set_property(__COMPONENT_REQUIRES_COMMON "${all_g0_components}")
  20. # Generate a graph to visually see the dependencies between G0 and G1+ (if any)
  21. idf_build_set_property(__BUILD_COMPONENT_DEPGRAPH_ENABLED 1)
  22. project(g0_components)
  23. if(CONFIG_IDF_TARGET_ESP32C2)
  24. # clk_tree hal-driver needs CONFIG_XTAL_FREQ
  25. idf_build_set_property(C_COMPILE_OPTIONS "-DCONFIG_XTAL_FREQ=26" APPEND)
  26. endif()
  27. # Currently, only support a single core on Xtensa targets.
  28. if(CONFIG_IDF_TARGET_ARCH_XTENSA)
  29. idf_build_set_property(C_COMPILE_OPTIONS "-DportNUM_PROCESSORS=1" APPEND)
  30. idf_build_set_property(ASM_COMPILE_OPTIONS "-DportNUM_PROCESSORS=1" APPEND)
  31. endif()
  32. # Now that the project has been initialized, let's check which components it is using
  33. # The following variable lists all the components that shall be used by this project
  34. set(expected_components
  35. ${COMPONENTS}
  36. ${CONFIG_IDF_TARGET_ARCH} # xtensa or riscv
  37. )
  38. # Do not include libc into the build, we don't have any libC in G0
  39. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")
  40. # Get all the components that were required to initialize this project
  41. idf_build_get_property(build_components BUILD_COMPONENTS)
  42. # Sort lists to be able to compare them literally
  43. list(SORT expected_components)
  44. list(SORT build_components)
  45. if(NOT "${expected_components}" STREQUAL "${build_components}")
  46. message(FATAL_ERROR "Unexpected components list in G0 build\n"
  47. "Expected: ${expected_components}\n"
  48. "Actual: ${build_components}")
  49. endif()