project.cmake 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. # Designed to be included from an IDF app's CMakeLists.txt file
  2. cmake_minimum_required(VERSION 3.5)
  3. include(${CMAKE_CURRENT_LIST_DIR}/targets.cmake)
  4. # Initialize build target for this build using the environment variable or
  5. # value passed externally.
  6. __target_init()
  7. # The mere inclusion of this CMake file sets up some interal build properties.
  8. # These properties can be modified in between this inclusion the the idf_build_process
  9. # call.
  10. include(${CMAKE_CURRENT_LIST_DIR}/idf.cmake)
  11. # setting PYTHON variable here for compatibility only, new code should use
  12. # idf_build_get_property(variable PYTHON)
  13. idf_build_get_property(PYTHON PYTHON)
  14. if(NOT PYTHON)
  15. message(FATAL_ERROR "Internal error, PYTHON build property not set correctly.")
  16. endif()
  17. # legacy variable for compatibility
  18. set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py")
  19. # On processing, checking Python required modules can be turned off if it was
  20. # already checked externally.
  21. if(PYTHON_DEPS_CHECKED)
  22. idf_build_set_property(__CHECK_PYTHON 0)
  23. endif()
  24. # Store CMake arguments that need to be passed into all CMake sub-projects as well
  25. # (bootloader, ULP, etc)
  26. #
  27. # It's not possible to tell if CMake was called with --warn-uninitialized, so to also
  28. # have these warnings in sub-projects we set a cache variable as well and then check that.
  29. if(WARN_UNINITIALIZED)
  30. idf_build_set_property(EXTRA_CMAKE_ARGS --warn-uninitialized)
  31. else()
  32. idf_build_set_property(EXTRA_CMAKE_ARGS "")
  33. endif()
  34. #
  35. # Get the project version from either a version file or the Git revision. This is passed
  36. # to the idf_build_process call. Dependencies are also set here for when the version file
  37. # changes (if it is used).
  38. #
  39. function(__project_get_revision var)
  40. set(_project_path "${CMAKE_CURRENT_LIST_DIR}")
  41. if(NOT DEFINED PROJECT_VER)
  42. if(EXISTS "${_project_path}/version.txt")
  43. file(STRINGS "${_project_path}/version.txt" PROJECT_VER)
  44. set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_project_path}/version.txt")
  45. else()
  46. git_describe(PROJECT_VER_GIT "${_project_path}")
  47. if(PROJECT_VER_GIT)
  48. set(PROJECT_VER ${PROJECT_VER_GIT})
  49. else()
  50. message(STATUS "Project is not inside a git repository, or git repository has no commits;"
  51. " will not use 'git describe' to determine PROJECT_VER.")
  52. set(PROJECT_VER 1)
  53. endif()
  54. endif()
  55. endif()
  56. set(${var} "${PROJECT_VER}" PARENT_SCOPE)
  57. endfunction()
  58. #
  59. # Output the built components to the user. Generates files for invoking idf_monitor.py
  60. # that doubles as an overview of some of the more important build properties.
  61. #
  62. function(__project_info test_components)
  63. idf_build_get_property(prefix __PREFIX)
  64. idf_build_get_property(_build_components BUILD_COMPONENTS)
  65. idf_build_get_property(build_dir BUILD_DIR)
  66. idf_build_get_property(idf_path IDF_PATH)
  67. list(SORT _build_components)
  68. unset(build_components)
  69. unset(build_component_paths)
  70. foreach(build_component ${_build_components})
  71. __component_get_target(component_target "${build_component}")
  72. __component_get_property(_name ${component_target} COMPONENT_NAME)
  73. __component_get_property(_prefix ${component_target} __PREFIX)
  74. __component_get_property(_alias ${component_target} COMPONENT_ALIAS)
  75. __component_get_property(_dir ${component_target} COMPONENT_DIR)
  76. if(_alias IN_LIST test_components)
  77. list(APPEND test_component_paths ${_dir})
  78. else()
  79. if(_prefix STREQUAL prefix)
  80. set(component ${_name})
  81. else()
  82. set(component ${_alias})
  83. endif()
  84. list(APPEND build_components ${component})
  85. list(APPEND build_component_paths ${_dir})
  86. endif()
  87. endforeach()
  88. set(PROJECT_NAME ${CMAKE_PROJECT_NAME})
  89. idf_build_get_property(PROJECT_PATH PROJECT_DIR)
  90. idf_build_get_property(BUILD_DIR BUILD_DIR)
  91. idf_build_get_property(SDKCONFIG SDKCONFIG)
  92. idf_build_get_property(SDKCONFIG_DEFAULTS SDKCONFIG_DEFAULTS)
  93. idf_build_get_property(PROJECT_EXECUTABLE EXECUTABLE)
  94. set(PROJECT_BIN ${CMAKE_PROJECT_NAME}.bin)
  95. idf_build_get_property(IDF_VER IDF_VER)
  96. idf_build_get_property(sdkconfig_cmake SDKCONFIG_CMAKE)
  97. include(${sdkconfig_cmake})
  98. idf_build_get_property(COMPONENT_KCONFIGS KCONFIGS)
  99. idf_build_get_property(COMPONENT_KCONFIGS_PROJBUILD KCONFIG_PROJBUILDS)
  100. idf_build_get_property(debug_prefix_map_gdbinit DEBUG_PREFIX_MAP_GDBINIT)
  101. # Write project description JSON file
  102. idf_build_get_property(build_dir BUILD_DIR)
  103. make_json_list("${build_components};${test_components}" build_components_json)
  104. make_json_list("${build_component_paths};${test_component_paths}" build_component_paths_json)
  105. configure_file("${idf_path}/tools/cmake/project_description.json.in"
  106. "${build_dir}/project_description.json")
  107. # We now have the following component-related variables:
  108. #
  109. # build_components is the list of components to include in the build.
  110. # build_component_paths is the paths to all of these components, obtained from the component dependencies file.
  111. #
  112. # Print the list of found components and test components
  113. string(REPLACE ";" " " build_components "${build_components}")
  114. string(REPLACE ";" " " build_component_paths "${build_component_paths}")
  115. message(STATUS "Components: ${build_components}")
  116. message(STATUS "Component paths: ${build_component_paths}")
  117. if(test_components)
  118. string(REPLACE ";" " " test_components "${test_components}")
  119. string(REPLACE ";" " " test_component_paths "${test_component_paths}")
  120. message(STATUS "Test components: ${test_components}")
  121. message(STATUS "Test component paths: ${test_component_paths}")
  122. endif()
  123. endfunction()
  124. function(__project_init components_var test_components_var)
  125. # Use EXTRA_CFLAGS, EXTRA_CXXFLAGS and EXTRA_CPPFLAGS to add more priority options to the compiler
  126. # EXTRA_CPPFLAGS is used for both C and C++
  127. # Unlike environments' CFLAGS/CXXFLAGS/CPPFLAGS which work for both host and target build,
  128. # these works only for target build
  129. set(extra_cflags "$ENV{EXTRA_CFLAGS}")
  130. set(extra_cxxflags "$ENV{EXTRA_CXXFLAGS}")
  131. set(extra_cppflags "$ENV{EXTRA_CPPFLAGS}")
  132. spaces2list(extra_cflags)
  133. spaces2list(extra_cxxflags)
  134. spaces2list(extra_cppflags)
  135. idf_build_set_property(C_COMPILE_OPTIONS "${extra_cflags}" APPEND)
  136. idf_build_set_property(CXX_COMPILE_OPTIONS "${extra_cxxflags}" APPEND)
  137. idf_build_set_property(COMPILE_OPTIONS "${extra_cppflags}" APPEND)
  138. function(__project_component_dir component_dir)
  139. get_filename_component(component_dir "${component_dir}" ABSOLUTE)
  140. # The directory itself is a valid idf component
  141. if(EXISTS ${component_dir}/CMakeLists.txt)
  142. idf_build_component(${component_dir})
  143. else()
  144. # otherwise, check whether the subfolders are potential idf components
  145. file(GLOB component_dirs ${component_dir}/*)
  146. foreach(component_dir ${component_dirs})
  147. if(IS_DIRECTORY ${component_dir})
  148. __component_dir_quick_check(is_component ${component_dir})
  149. if(is_component)
  150. idf_build_component(${component_dir})
  151. endif()
  152. endif()
  153. endforeach()
  154. endif()
  155. endfunction()
  156. # Add component directories to the build, given the component filters, exclusions
  157. # extra directories, etc. passed from the root CMakeLists.txt.
  158. if(COMPONENT_DIRS)
  159. # User wants to fully override where components are pulled from.
  160. spaces2list(COMPONENT_DIRS)
  161. idf_build_set_property(__COMPONENT_TARGETS "")
  162. foreach(component_dir ${COMPONENT_DIRS})
  163. __project_component_dir(${component_dir})
  164. endforeach()
  165. else()
  166. if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/main")
  167. __project_component_dir("${CMAKE_CURRENT_LIST_DIR}/main")
  168. endif()
  169. spaces2list(EXTRA_COMPONENT_DIRS)
  170. foreach(component_dir ${EXTRA_COMPONENT_DIRS})
  171. __project_component_dir("${component_dir}")
  172. endforeach()
  173. # Look for components in the usual places: CMAKE_CURRENT_LIST_DIR/main,
  174. # extra component dirs, and CMAKE_CURRENT_LIST_DIR/components
  175. __project_component_dir("${CMAKE_CURRENT_LIST_DIR}/components")
  176. endif()
  177. # For bootloader components, we only need to set-up the Kconfig files.
  178. # Indeed, bootloader is currently compiled as a subproject, thus,
  179. # its components are not part of the main project.
  180. # However, in order to be able to configure these bootloader components
  181. # using menuconfig, we need to look for their Kconfig-related files now.
  182. file(GLOB bootloader_component_dirs "${CMAKE_CURRENT_LIST_DIR}/bootloader_components/*")
  183. list(SORT bootloader_component_dirs)
  184. foreach(bootloader_component_dir ${bootloader_component_dirs})
  185. if(IS_DIRECTORY ${bootloader_component_dir})
  186. __component_dir_quick_check(is_component ${bootloader_component_dir})
  187. if(is_component)
  188. __kconfig_bootloader_component_add("${bootloader_component_dir}")
  189. endif()
  190. endif()
  191. endforeach()
  192. spaces2list(COMPONENTS)
  193. spaces2list(EXCLUDE_COMPONENTS)
  194. idf_build_get_property(component_targets __COMPONENT_TARGETS)
  195. foreach(component_target ${component_targets})
  196. __component_get_property(component_name ${component_target} COMPONENT_NAME)
  197. set(include 1)
  198. if(COMPONENTS AND NOT component_name IN_LIST COMPONENTS)
  199. set(include 0)
  200. endif()
  201. if(EXCLUDE_COMPONENTS AND component_name IN_LIST EXCLUDE_COMPONENTS)
  202. set(include 0)
  203. endif()
  204. if(include)
  205. list(APPEND components ${component_name})
  206. endif()
  207. endforeach()
  208. if(TESTS_ALL OR BUILD_TESTS OR TEST_COMPONENTS OR TEST_EXCLUDE_COMPONENTS)
  209. spaces2list(TEST_COMPONENTS)
  210. spaces2list(TEST_EXCLUDE_COMPONENTS)
  211. idf_build_get_property(component_targets __COMPONENT_TARGETS)
  212. foreach(component_target ${component_targets})
  213. __component_get_property(component_dir ${component_target} COMPONENT_DIR)
  214. __component_get_property(component_name ${component_target} COMPONENT_NAME)
  215. if(component_name IN_LIST components)
  216. set(include 1)
  217. if(TEST_COMPONENTS AND NOT component_name IN_LIST TEST_COMPONENTS)
  218. set(include 0)
  219. endif()
  220. if(TEST_EXCLUDE_COMPONENTS AND component_name IN_LIST TEST_EXCLUDE_COMPONENTS)
  221. set(include 0)
  222. endif()
  223. if(include AND EXISTS ${component_dir}/test)
  224. __component_add(${component_dir}/test ${component_name})
  225. list(APPEND test_components ${component_name}::test)
  226. endif()
  227. endif()
  228. endforeach()
  229. endif()
  230. set(${components_var} "${components}" PARENT_SCOPE)
  231. set(${test_components_var} "${test_components}" PARENT_SCOPE)
  232. endfunction()
  233. # Trick to temporarily redefine project(). When functions are overriden in CMake, the originals can still be accessed
  234. # using an underscore prefixed function of the same name. The following lines make sure that __project calls
  235. # the original project(). See https://cmake.org/pipermail/cmake/2015-October/061751.html.
  236. function(project)
  237. endfunction()
  238. function(_project)
  239. endfunction()
  240. macro(project project_name)
  241. # Initialize project, preparing COMPONENTS argument for idf_build_process()
  242. # call later using external COMPONENT_DIRS, COMPONENTS_DIRS, EXTRA_COMPONENTS_DIR,
  243. # EXTRA_COMPONENTS_DIRS, COMPONENTS, EXLUDE_COMPONENTS, TEST_COMPONENTS,
  244. # TEST_EXLUDE_COMPONENTS, TESTS_ALL, BUILD_TESTS
  245. __project_init(components test_components)
  246. __target_set_toolchain()
  247. if(CCACHE_ENABLE)
  248. find_program(CCACHE_FOUND ccache)
  249. if(CCACHE_FOUND)
  250. message(STATUS "ccache will be used for faster recompilation")
  251. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
  252. else()
  253. message(WARNING "enabled ccache in build but ccache program not found")
  254. endif()
  255. endif()
  256. # The actual call to project()
  257. __project(${project_name} C CXX ASM)
  258. # Generate compile_commands.json (needs to come after project call).
  259. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  260. # Since components can import third-party libraries, the original definition of project() should be restored
  261. # before the call to add components to the build.
  262. function(project)
  263. set(project_ARGV ARGV)
  264. __project(${${project_ARGV}})
  265. # Set the variables that project() normally sets, documented in the
  266. # command's docs.
  267. #
  268. # https://cmake.org/cmake/help/v3.5/command/project.html
  269. #
  270. # There is some nuance when it comes to setting version variables in terms of whether
  271. # CMP0048 is set to OLD or NEW. However, the proper behavior should have bee already handled by the original
  272. # project call, and we're just echoing the values those variables were set to.
  273. set(PROJECT_NAME "${PROJECT_NAME}" PARENT_SCOPE)
  274. set(PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}" PARENT_SCOPE)
  275. set(PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}" PARENT_SCOPE)
  276. set(PROJECT_VERSION "${PROJECT_VERSION}" PARENT_SCOPE)
  277. set(PROJECT_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}" PARENT_SCOPE)
  278. set(PROJECT_VERSION_MINOR "${PROJECT_VERSION_MINOR}" PARENT_SCOPE)
  279. set(PROJECT_VERSION_PATCH "${PROJECT_VERSION_PATCH}" PARENT_SCOPE)
  280. set(PROJECT_VERSION_TWEAK "${PROJECT_VERSION_TWEAK}" PARENT_SCOPE)
  281. set(${PROJECT_NAME}_BINARY_DIR "${${PROJECT_NAME}_BINARY_DIR}" PARENT_SCOPE)
  282. set(${PROJECT_NAME}_SOURCE_DIR "${${PROJECT_NAME}_SOURCE_DIR}" PARENT_SCOPE)
  283. set(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION}" PARENT_SCOPE)
  284. set(${PROJECT_NAME}_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}" PARENT_SCOPE)
  285. set(${PROJECT_NAME}_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}" PARENT_SCOPE)
  286. set(${PROJECT_NAME}_VERSION_PATCH "${${PROJECT_NAME}_VERSION_PATCH}" PARENT_SCOPE)
  287. set(${PROJECT_NAME}_VERSION_TWEAK "${${PROJECT_NAME}_VERSION_TWEAK}" PARENT_SCOPE)
  288. endfunction()
  289. # Prepare the following arguments for the idf_build_process() call using external
  290. # user values:
  291. #
  292. # SDKCONFIG_DEFAULTS is from external SDKCONFIG_DEFAULTS
  293. # SDKCONFIG is from external SDKCONFIG
  294. # BUILD_DIR is set to project binary dir
  295. #
  296. # PROJECT_NAME is taken from the passed name from project() call
  297. # PROJECT_DIR is set to the current directory
  298. # PROJECT_VER is from the version text or git revision of the current repo
  299. set(_sdkconfig_defaults "$ENV{SDKCONFIG_DEFAULTS}")
  300. if(NOT _sdkconfig_defaults)
  301. if(EXISTS "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
  302. set(_sdkconfig_defaults "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
  303. else()
  304. set(_sdkconfig_defaults "")
  305. endif()
  306. endif()
  307. if(SDKCONFIG_DEFAULTS)
  308. set(_sdkconfig_defaults "${SDKCONFIG_DEFAULTS}")
  309. endif()
  310. foreach(sdkconfig_default ${_sdkconfig_defaults})
  311. get_filename_component(sdkconfig_default "${sdkconfig_default}" ABSOLUTE)
  312. if(NOT EXISTS "${sdkconfig_default}")
  313. message(FATAL_ERROR "SDKCONFIG_DEFAULTS '${sdkconfig_default}' does not exist.")
  314. endif()
  315. list(APPEND sdkconfig_defaults ${sdkconfig_default})
  316. endforeach()
  317. if(SDKCONFIG)
  318. get_filename_component(sdkconfig "${SDKCONFIG}" ABSOLUTE)
  319. else()
  320. set(sdkconfig "${CMAKE_CURRENT_LIST_DIR}/sdkconfig")
  321. endif()
  322. if(BUILD_DIR)
  323. get_filename_component(build_dir "${BUILD_DIR}" ABSOLUTE)
  324. if(NOT EXISTS "${build_dir}")
  325. message(FATAL_ERROR "BUILD_DIR '${build_dir}' does not exist.")
  326. endif()
  327. else()
  328. set(build_dir ${CMAKE_BINARY_DIR})
  329. endif()
  330. __project_get_revision(project_ver)
  331. message(STATUS "Building ESP-IDF components for target ${IDF_TARGET}")
  332. idf_build_process(${IDF_TARGET}
  333. SDKCONFIG_DEFAULTS "${sdkconfig_defaults}"
  334. SDKCONFIG ${sdkconfig}
  335. BUILD_DIR ${build_dir}
  336. PROJECT_NAME ${CMAKE_PROJECT_NAME}
  337. PROJECT_DIR ${CMAKE_CURRENT_LIST_DIR}
  338. PROJECT_VER "${project_ver}"
  339. COMPONENTS "${components};${test_components}")
  340. # Special treatment for 'main' component for standard projects (not part of core build system).
  341. # Have it depend on every other component in the build. This is
  342. # a convenience behavior for the standard project; thus is done outside of the core build system
  343. # so that it treats components equally.
  344. #
  345. # This behavior should only be when user did not set REQUIRES/PRIV_REQUIRES manually.
  346. idf_build_get_property(build_components BUILD_COMPONENT_ALIASES)
  347. if(idf::main IN_LIST build_components)
  348. __component_get_target(main_target idf::main)
  349. __component_get_property(reqs ${main_target} REQUIRES)
  350. __component_get_property(priv_reqs ${main_target} PRIV_REQUIRES)
  351. idf_build_get_property(common_reqs __COMPONENT_REQUIRES_COMMON)
  352. if(reqs STREQUAL common_reqs AND NOT priv_reqs) #if user has not set any requirements
  353. if(test_components)
  354. list(REMOVE_ITEM build_components ${test_components})
  355. endif()
  356. list(REMOVE_ITEM build_components idf::main)
  357. __component_get_property(lib ${main_target} COMPONENT_LIB)
  358. set_property(TARGET ${lib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${build_components}")
  359. get_property(type TARGET ${lib} PROPERTY TYPE)
  360. if(type STREQUAL STATIC_LIBRARY)
  361. set_property(TARGET ${lib} APPEND PROPERTY LINK_LIBRARIES "${build_components}")
  362. endif()
  363. endif()
  364. endif()
  365. set(project_elf ${CMAKE_PROJECT_NAME}.elf)
  366. # Create a dummy file to work around CMake requirement of having a source file while adding an
  367. # executable. This is also used by idf_size.py to detect the target
  368. set(project_elf_src ${CMAKE_BINARY_DIR}/project_elf_src_${IDF_TARGET}.c)
  369. add_custom_command(OUTPUT ${project_elf_src}
  370. COMMAND ${CMAKE_COMMAND} -E touch ${project_elf_src}
  371. VERBATIM)
  372. add_custom_target(_project_elf_src DEPENDS "${project_elf_src}")
  373. add_executable(${project_elf} "${project_elf_src}")
  374. add_dependencies(${project_elf} _project_elf_src)
  375. if(__PROJECT_GROUP_LINK_COMPONENTS)
  376. target_link_libraries(${project_elf} "-Wl,--start-group")
  377. endif()
  378. if(test_components)
  379. target_link_libraries(${project_elf} "-Wl,--whole-archive")
  380. foreach(test_component ${test_components})
  381. if(TARGET ${test_component})
  382. target_link_libraries(${project_elf} ${test_component})
  383. endif()
  384. endforeach()
  385. target_link_libraries(${project_elf} "-Wl,--no-whole-archive")
  386. endif()
  387. idf_build_get_property(build_components BUILD_COMPONENT_ALIASES)
  388. if(test_components)
  389. list(REMOVE_ITEM build_components ${test_components})
  390. endif()
  391. target_link_libraries(${project_elf} ${build_components})
  392. if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
  393. set(mapfile "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.map")
  394. set(idf_target "${IDF_TARGET}")
  395. string(TOUPPER ${idf_target} idf_target)
  396. target_link_libraries(${project_elf} "-Wl,--cref" "-Wl,--defsym=IDF_TARGET_${idf_target}=0"
  397. "-Wl,--Map=\"${mapfile}\"")
  398. unset(idf_target)
  399. endif()
  400. set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
  401. ADDITIONAL_MAKE_CLEAN_FILES
  402. "${mapfile}" "${project_elf_src}")
  403. idf_build_get_property(idf_path IDF_PATH)
  404. idf_build_get_property(python PYTHON)
  405. set(idf_size ${python} ${idf_path}/tools/idf_size.py)
  406. if(DEFINED OUTPUT_JSON AND OUTPUT_JSON)
  407. list(APPEND idf_size "--json")
  408. endif()
  409. # Add size targets, depend on map file, run idf_size.py
  410. add_custom_target(size
  411. DEPENDS ${mapfile}
  412. COMMAND ${idf_size} ${mapfile}
  413. )
  414. add_custom_target(size-files
  415. DEPENDS ${mapfile}
  416. COMMAND ${idf_size} --files ${mapfile}
  417. )
  418. add_custom_target(size-components
  419. DEPENDS ${mapfile}
  420. COMMAND ${idf_size} --archives ${mapfile}
  421. )
  422. unset(idf_size)
  423. # Add DFU build and flash targets
  424. __add_dfu_targets()
  425. # Add UF2 build targets
  426. __add_uf2_targets()
  427. idf_build_executable(${project_elf})
  428. __project_info("${test_components}")
  429. endmacro()