component.cmake 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. #
  2. # Internal function for retrieving component properties from a component target.
  3. #
  4. function(__component_get_property var component_target property)
  5. get_property(val TARGET ${component_target} PROPERTY ${property})
  6. set(${var} "${val}" PARENT_SCOPE)
  7. endfunction()
  8. #
  9. # Internal function for setting component properties on a component target. As with build properties,
  10. # set properties are also keeped track of.
  11. #
  12. function(__component_set_property component_target property val)
  13. cmake_parse_arguments(_ "APPEND" "" "" ${ARGN})
  14. if(__APPEND)
  15. set_property(TARGET ${component_target} APPEND PROPERTY ${property} "${val}")
  16. else()
  17. set_property(TARGET ${component_target} PROPERTY ${property} "${val}")
  18. endif()
  19. # Keep track of set component properties
  20. __component_get_property(properties ${component_target} __COMPONENT_PROPERTIES)
  21. if(NOT property IN_LIST properties)
  22. __component_set_property(${component_target} __COMPONENT_PROPERTIES ${property} APPEND)
  23. endif()
  24. endfunction()
  25. #
  26. # Given a component name or alias, get the corresponding component target.
  27. #
  28. function(__component_get_target var name_or_alias)
  29. # Look at previously resolved names or aliases
  30. idf_build_get_property(component_names_resolved __COMPONENT_NAMES_RESOLVED)
  31. list(FIND component_names_resolved ${name_or_alias} result)
  32. if(NOT result EQUAL -1)
  33. # If it has been resolved before, return that value. The index is the same
  34. # as in __COMPONENT_NAMES_RESOLVED as these are parallel lists.
  35. idf_build_get_property(component_targets_resolved __COMPONENT_TARGETS_RESOLVED)
  36. list(GET component_targets_resolved ${result} target)
  37. set(${var} ${target} PARENT_SCOPE)
  38. return()
  39. endif()
  40. idf_build_get_property(component_targets __COMPONENT_TARGETS)
  41. # Assume first that the paramters is an alias.
  42. string(REPLACE "::" "_" name_or_alias "${name_or_alias}")
  43. set(component_target ___${name_or_alias})
  44. if(component_target IN_LIST component_targets)
  45. set(${var} ${component_target} PARENT_SCOPE)
  46. set(target ${component_target})
  47. else() # assumption is wrong, try to look for it manually
  48. unset(target)
  49. foreach(component_target ${component_targets})
  50. __component_get_property(_component_name ${component_target} COMPONENT_NAME)
  51. if(name_or_alias STREQUAL _component_name)
  52. # There should only be one component of the same name
  53. if(NOT target)
  54. set(target ${component_target})
  55. else()
  56. message(FATAL_ERROR "Multiple components with name '${name_or_alias}' found.")
  57. return()
  58. endif()
  59. endif()
  60. endforeach()
  61. set(${var} ${target} PARENT_SCOPE)
  62. endif()
  63. # Save the resolved name or alias
  64. if(target)
  65. idf_build_set_property(__COMPONENT_NAMES_RESOLVED ${name_or_alias} APPEND)
  66. idf_build_set_property(__COMPONENT_TARGETS_RESOLVED ${target} APPEND)
  67. endif()
  68. endfunction()
  69. #
  70. # Called during component registration, sets basic properties of the current component.
  71. #
  72. macro(__component_set_properties)
  73. __component_get_property(type ${component_target} COMPONENT_TYPE)
  74. # Fill in the rest of component property
  75. __component_set_property(${component_target} SRCS "${sources}")
  76. __component_set_property(${component_target} INCLUDE_DIRS "${__INCLUDE_DIRS}")
  77. if(type STREQUAL LIBRARY)
  78. __component_set_property(${component_target} PRIV_INCLUDE_DIRS "${__PRIV_INCLUDE_DIRS}")
  79. endif()
  80. __component_set_property(${component_target} LDFRAGMENTS "${__LDFRAGMENTS}")
  81. __component_set_property(${component_target} EMBED_FILES "${__EMBED_FILES}")
  82. __component_set_property(${component_target} EMBED_TXTFILES "${__EMBED_TXTFILES}")
  83. __component_set_property(${component_target} REQUIRED_IDF_TARGETS "${__REQUIRED_IDF_TARGETS}")
  84. endmacro()
  85. #
  86. # Perform a quick check if given component dir satisfies basic requirements.
  87. #
  88. function(__component_dir_quick_check var component_dir)
  89. set(res 1)
  90. get_filename_component(abs_dir ${component_dir} ABSOLUTE)
  91. # Check this is really a directory and that a CMakeLists.txt file for this component exists
  92. # - warn and skip anything which isn't valid looking (probably cruft)
  93. if(NOT IS_DIRECTORY "${abs_dir}")
  94. message(STATUS "Unexpected file in components directory: ${abs_dir}")
  95. set(res 0)
  96. endif()
  97. get_filename_component(base_dir ${abs_dir} NAME)
  98. string(SUBSTRING "${base_dir}" 0 1 first_char)
  99. if(NOT first_char STREQUAL ".")
  100. if(NOT EXISTS "${abs_dir}/CMakeLists.txt")
  101. message(STATUS "Component directory ${abs_dir} does not contain a CMakeLists.txt file. "
  102. "No component will be added")
  103. set(res 0)
  104. endif()
  105. else()
  106. set(res 0) # quietly ignore dot-folders
  107. endif()
  108. set(${var} ${res} PARENT_SCOPE)
  109. endfunction()
  110. #
  111. # Write a CMake file containing all component and their properties. This is possible because each component
  112. # keeps a list of all its properties.
  113. #
  114. function(__component_write_properties output_file)
  115. idf_build_get_property(component_targets __COMPONENT_TARGETS)
  116. foreach(component_target ${component_targets})
  117. __component_get_property(component_properties ${component_target} __COMPONENT_PROPERTIES)
  118. foreach(property ${component_properties})
  119. __component_get_property(val ${component_target} ${property})
  120. set(component_properties_text
  121. "${component_properties_text}\nset(__component_${component_target}_${property} ${val})")
  122. endforeach()
  123. file(WRITE ${output_file} "${component_properties_text}")
  124. endforeach()
  125. endfunction()
  126. #
  127. # Add a component to process in the build. The components are keeped tracked of in property
  128. # __COMPONENT_TARGETS in component target form.
  129. #
  130. function(__component_add component_dir prefix)
  131. # For each component, two entities are created: a component target and a component library. The
  132. # component library is created during component registration (the actual static/interface library).
  133. # On the other hand, component targets are created early in the build
  134. # (during adding component as this function suggests).
  135. # This is so that we still have a target to attach properties to up until the component registration.
  136. # Plus, interface libraries have limitations on the types of properties that can be set on them,
  137. # so later in the build, these component targets actually contain the properties meant for the
  138. # corresponding component library.
  139. idf_build_get_property(component_targets __COMPONENT_TARGETS)
  140. get_filename_component(abs_dir ${component_dir} ABSOLUTE)
  141. get_filename_component(base_dir ${abs_dir} NAME)
  142. if(NOT EXISTS "${abs_dir}/CMakeLists.txt")
  143. message(FATAL_ERROR "Directory '${component_dir}' does not contain a component.")
  144. endif()
  145. set(component_name ${base_dir})
  146. # The component target has three underscores as a prefix. The corresponding component library
  147. # only has two.
  148. set(component_target ___${prefix}_${component_name})
  149. # If a component of the same name has not been added before If it has been added
  150. # before just override the properties. As a side effect, components added later
  151. # 'override' components added earlier.
  152. if(NOT component_target IN_LIST component_targets)
  153. if(NOT TARGET ${component_target})
  154. add_custom_target(${component_target} EXCLUDE_FROM_ALL)
  155. endif()
  156. idf_build_set_property(__COMPONENT_TARGETS ${component_target} APPEND)
  157. endif()
  158. set(component_lib __${prefix}_${component_name})
  159. set(component_dir ${abs_dir})
  160. set(component_alias ${prefix}::${component_name}) # The 'alias' of the component library,
  161. # used to refer to the component outside
  162. # the build system. Users can use this name
  163. # to resolve ambiguity with component names
  164. # and to link IDF components to external targets.
  165. # Set the basic properties of the component
  166. __component_set_property(${component_target} COMPONENT_LIB ${component_lib})
  167. __component_set_property(${component_target} COMPONENT_NAME ${component_name})
  168. __component_set_property(${component_target} COMPONENT_DIR ${component_dir})
  169. __component_set_property(${component_target} COMPONENT_ALIAS ${component_alias})
  170. __component_set_property(${component_target} __PREFIX ${prefix})
  171. # Set Kconfig related properties on the component
  172. __kconfig_component_init(${component_target})
  173. endfunction()
  174. #
  175. # Given a component directory, get the requirements by expanding it early. The expansion is performed
  176. # using a separate CMake script (the expansion is performed in a separate instance of CMake in scripting mode).
  177. #
  178. function(__component_get_requirements)
  179. idf_build_get_property(idf_path IDF_PATH)
  180. idf_build_get_property(build_dir BUILD_DIR)
  181. set(build_properties_file ${build_dir}/build_properties.temp.cmake)
  182. set(component_properties_file ${build_dir}/component_properties.temp.cmake)
  183. set(component_requires_file ${build_dir}/component_requires.temp.cmake)
  184. __build_write_properties(${build_properties_file})
  185. __component_write_properties(${component_properties_file})
  186. execute_process(COMMAND "${CMAKE_COMMAND}"
  187. -D "ESP_PLATFORM=1"
  188. -D "BUILD_PROPERTIES_FILE=${build_properties_file}"
  189. -D "COMPONENT_PROPERTIES_FILE=${component_properties_file}"
  190. -D "COMPONENT_REQUIRES_FILE=${component_requires_file}"
  191. -P "${idf_path}/tools/cmake/scripts/component_get_requirements.cmake"
  192. RESULT_VARIABLE result
  193. ERROR_VARIABLE error
  194. )
  195. if(NOT result EQUAL 0)
  196. message(FATAL_ERROR "${error}")
  197. endif()
  198. include(${component_requires_file})
  199. file(REMOVE ${build_properties_file})
  200. file(REMOVE ${component_properties_file})
  201. file(REMOVE ${component_requires_file})
  202. endfunction()
  203. # __component_add_sources, __component_check_target, __component_add_include_dirs
  204. #
  205. # Utility macros for component registration. Adds source files and checks target requirements,
  206. # and adds include directories respectively.
  207. macro(__component_add_sources sources)
  208. set(sources "")
  209. if(__SRCS)
  210. if(__SRC_DIRS)
  211. message(WARNING "SRCS and SRC_DIRS are both specified; ignoring SRC_DIRS.")
  212. endif()
  213. foreach(src ${__SRCS})
  214. get_filename_component(src "${src}" ABSOLUTE BASE_DIR ${COMPONENT_DIR})
  215. list(APPEND sources ${src})
  216. endforeach()
  217. else()
  218. if(__SRC_DIRS)
  219. foreach(dir ${__SRC_DIRS})
  220. get_filename_component(abs_dir ${dir} ABSOLUTE BASE_DIR ${COMPONENT_DIR})
  221. if(NOT IS_DIRECTORY ${abs_dir})
  222. message(FATAL_ERROR "SRC_DIRS entry '${dir}' does not exist.")
  223. endif()
  224. file(GLOB dir_sources "${abs_dir}/*.c" "${abs_dir}/*.cpp" "${abs_dir}/*.S")
  225. if(dir_sources)
  226. foreach(src ${dir_sources})
  227. get_filename_component(src "${src}" ABSOLUTE BASE_DIR ${COMPONENT_DIR})
  228. list(APPEND sources "${src}")
  229. endforeach()
  230. else()
  231. message(WARNING "No source files found for SRC_DIRS entry '${dir}'.")
  232. endif()
  233. endforeach()
  234. endif()
  235. if(__EXCLUDE_SRCS)
  236. foreach(src ${__EXCLUDE_SRCS})
  237. get_filename_component(src "${src}" ABSOLUTE)
  238. list(REMOVE_ITEM sources "${src}")
  239. endforeach()
  240. endif()
  241. endif()
  242. list(REMOVE_DUPLICATES sources)
  243. endmacro()
  244. macro(__component_add_include_dirs lib dirs type)
  245. foreach(dir ${dirs})
  246. get_filename_component(_dir ${dir} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_LIST_DIR})
  247. if(NOT IS_DIRECTORY ${_dir})
  248. message(FATAL_ERROR "Include directory '${_dir}' is not a directory.")
  249. endif()
  250. target_include_directories(${lib} ${type} ${_dir})
  251. endforeach()
  252. endmacro()
  253. macro(__component_check_target)
  254. if(__REQUIRED_IDF_TARGETS)
  255. idf_build_get_property(idf_target IDF_TARGET)
  256. if(NOT idf_target IN_LIST __REQUIRED_IDF_TARGETS)
  257. message(FATAL_ERROR "Component ${COMPONENT_NAME} only supports targets: ${__REQUIRED_IDF_TARGETS}")
  258. endif()
  259. endif()
  260. endmacro()
  261. # __component_set_dependencies, __component_set_all_dependencies
  262. #
  263. # Links public and private requirements for the currently processed component
  264. macro(__component_set_dependencies reqs type)
  265. foreach(req ${reqs})
  266. if(req IN_LIST build_component_targets)
  267. __component_get_property(req_lib ${req} COMPONENT_LIB)
  268. if("${type}" STREQUAL "PRIVATE")
  269. set_property(TARGET ${component_lib} APPEND PROPERTY LINK_LIBRARIES ${req_lib})
  270. set_property(TARGET ${component_lib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES $<LINK_ONLY:${req_lib}>)
  271. elseif("${type}" STREQUAL "PUBLIC")
  272. set_property(TARGET ${component_lib} APPEND PROPERTY LINK_LIBRARIES ${req_lib})
  273. set_property(TARGET ${component_lib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${req_lib})
  274. else() # INTERFACE
  275. set_property(TARGET ${component_lib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${req_lib})
  276. endif()
  277. endif()
  278. endforeach()
  279. endmacro()
  280. macro(__component_set_all_dependencies)
  281. __component_get_property(type ${component_target} COMPONENT_TYPE)
  282. idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)
  283. if(NOT type STREQUAL CONFIG_ONLY)
  284. __component_get_property(reqs ${component_target} __REQUIRES)
  285. __component_set_dependencies("${reqs}" PUBLIC)
  286. __component_get_property(priv_reqs ${component_target} __PRIV_REQUIRES)
  287. __component_set_dependencies("${priv_reqs}" PRIVATE)
  288. else()
  289. __component_get_property(reqs ${component_target} __REQUIRES)
  290. __component_set_dependencies("${reqs}" INTERFACE)
  291. endif()
  292. endmacro()
  293. # idf_component_get_property
  294. #
  295. # @brief Retrieve the value of the specified component property
  296. #
  297. # @param[out] var the variable to store the value of the property in
  298. # @param[in] component the component name or alias to get the value of the property of
  299. # @param[in] property the property to get the value of
  300. #
  301. # @param[in, optional] GENERATOR_EXPRESSION (option) retrieve the generator expression for the property
  302. # instead of actual value
  303. function(idf_component_get_property var component property)
  304. cmake_parse_arguments(_ "GENERATOR_EXPRESSION" "" "" ${ARGN})
  305. __component_get_target(component_target ${component})
  306. if(__GENERATOR_EXPRESSION)
  307. set(val "$<TARGET_PROPERTY:${component_target},${property}>")
  308. else()
  309. __component_get_property(val ${component_target} ${property})
  310. endif()
  311. set(${var} "${val}" PARENT_SCOPE)
  312. endfunction()
  313. # idf_component_set_property
  314. #
  315. # @brief Set the value of the specified component property related. The property is
  316. # also added to the internal list of component properties if it isn't there already.
  317. #
  318. # @param[in] component component name or alias of the component to set the property of
  319. # @param[in] property the property to set the value of
  320. # @param[out] value value of the property to set to
  321. #
  322. # @param[in, optional] APPEND (option) append the value to the current value of the
  323. # property instead of replacing it
  324. function(idf_component_set_property component property val)
  325. cmake_parse_arguments(_ "APPEND" "" "" ${ARGN})
  326. __component_get_target(component_target ${component})
  327. if(__APPEND)
  328. __component_set_property(${component_target} ${property} "${val}" APPEND)
  329. else()
  330. __component_set_property(${component_target} ${property} "${val}")
  331. endif()
  332. endfunction()
  333. # idf_component_register
  334. #
  335. # @brief Register a component to the build, creating component library targets etc.
  336. #
  337. # @param[in, optional] SRCS (multivalue) list of source files for the component
  338. # @param[in, optional] SRC_DIRS (multivalue) list of source directories to look for source files
  339. # in (.c, .cpp. .S); ignored when SRCS is specified.
  340. # @param[in, optional] EXCLUDE_SRCS (multivalue) used to exclude source files for the specified
  341. # SRC_DIRS
  342. # @param[in, optional] INCLUDE_DIRS (multivalue) public include directories for the created component library
  343. # @param[in, optional] PRIV_INCLUDE_DIRS (multivalue) private include directories for the created component library
  344. # @param[in, optional] LDFRAGMENTS (multivalue) linker script fragments for the component
  345. # @param[in, optional] REQUIRES (multivalue) publicly required components in terms of usage requirements
  346. # @param[in, optional] PRIV_REQUIRES (multivalue) privately required components in terms of usage requirements
  347. # or components only needed for functions/values defined in its project_include.cmake
  348. # @param[in, optional] REQUIRED_IDF_TARGETS (multivalue) the list of IDF build targets that the component only supports
  349. # @param[in, optional] EMBED_FILES (multivalue) list of binary files to embed with the component
  350. # @param[in, optional] EMBED_TXTFILES (multivalue) list of text files to embed with the component
  351. function(idf_component_register)
  352. set(options)
  353. set(single_value)
  354. set(multi_value SRCS SRC_DIRS EXCLUDE_SRCS
  355. INCLUDE_DIRS PRIV_INCLUDE_DIRS LDFRAGMENTS REQUIRES
  356. PRIV_REQUIRES REQUIRED_IDF_TARGETS EMBED_FILES EMBED_TXTFILES)
  357. cmake_parse_arguments(_ "${options}" "${single_value}" "${multi_value}" ${ARGN})
  358. if(NOT __idf_component_context)
  359. message(FATAL_ERROR "Called idf_component_register from a non-component directory.")
  360. endif()
  361. __component_check_target()
  362. __component_add_sources(sources)
  363. # Create the final target for the component. This target is the target that is
  364. # visible outside the build system.
  365. __component_get_target(component_target ${COMPONENT_ALIAS})
  366. __component_get_property(component_lib ${component_target} COMPONENT_LIB)
  367. # Use generator expression so that users can append/override flags even after call to
  368. # idf_build_process
  369. idf_build_get_property(include_directories INCLUDE_DIRECTORIES GENERATOR_EXPRESSION)
  370. idf_build_get_property(compile_options COMPILE_OPTIONS GENERATOR_EXPRESSION)
  371. idf_build_get_property(c_compile_options C_COMPILE_OPTIONS GENERATOR_EXPRESSION)
  372. idf_build_get_property(cxx_compile_options CXX_COMPILE_OPTIONS GENERATOR_EXPRESSION)
  373. idf_build_get_property(common_reqs ___COMPONENT_REQUIRES_COMMON)
  374. include_directories("${include_directories}")
  375. add_compile_options("${compile_options}")
  376. add_c_compile_options("${c_compile_options}")
  377. add_cxx_compile_options("${cxx_compile_options}")
  378. # Unfortunately add_definitions() does not support generator expressions. A new command
  379. # add_compile_definition() does but is only available on CMake 3.12 or newer. This uses
  380. # add_compile_options(), which can add any option as the workaround.
  381. #
  382. # TODO: Use add_compile_definitions() once minimum supported version is 3.12 or newer.
  383. idf_build_get_property(compile_definitions COMPILE_DEFINITIONS GENERATOR_EXPRESSION)
  384. add_compile_options("${compile_definitions}")
  385. list(REMOVE_ITEM common_reqs ${component_lib})
  386. link_libraries(${common_reqs})
  387. idf_build_get_property(config_dir CONFIG_DIR)
  388. # The contents of 'sources' is from the __component_add_sources call
  389. if(sources OR __EMBED_FILES OR __EMBED_TXTFILES)
  390. add_library(${component_lib} STATIC ${sources})
  391. __component_set_property(${component_target} COMPONENT_TYPE LIBRARY)
  392. __component_add_include_dirs(${component_lib} "${__INCLUDE_DIRS}" PUBLIC)
  393. __component_add_include_dirs(${component_lib} "${__PRIV_INCLUDE_DIRS}" PRIVATE)
  394. __component_add_include_dirs(${component_lib} "${config_dir}" PUBLIC)
  395. set_target_properties(${component_lib} PROPERTIES OUTPUT_NAME ${COMPONENT_NAME})
  396. __ldgen_add_component(${component_lib})
  397. else()
  398. add_library(${component_lib} INTERFACE)
  399. __component_set_property(${component_target} COMPONENT_TYPE CONFIG_ONLY)
  400. __component_add_include_dirs(${component_lib} "${__INCLUDE_DIRS}" INTERFACE)
  401. __component_add_include_dirs(${component_lib} "${config_dir}" INTERFACE)
  402. endif()
  403. # Alias the static/interface library created for linking to external targets.
  404. # The alias is the <prefix>::<component name> name.
  405. __component_get_property(component_alias ${component_target} COMPONENT_ALIAS)
  406. add_library(${component_alias} ALIAS ${component_lib})
  407. # Perform other component processing, such as embedding binaries and processing linker
  408. # script fragments
  409. foreach(file ${__EMBED_FILES})
  410. target_add_binary_data(${component_lib} "${file}" "BINARY")
  411. endforeach()
  412. foreach(file ${__EMBED_TXTFILES})
  413. target_add_binary_data(${component_lib} "${file}" "TEXT")
  414. endforeach()
  415. if(__LDFRAGMENTS)
  416. __ldgen_add_fragment_files("${__LDFRAGMENTS}")
  417. endif()
  418. # Set dependencies
  419. __component_set_all_dependencies()
  420. # Add the component to built components
  421. idf_build_set_property(__BUILD_COMPONENTS ${component_lib} APPEND)
  422. idf_build_set_property(BUILD_COMPONENTS ${component_alias} APPEND)
  423. # Make the COMPONENT_LIB variable available in the component CMakeLists.txt
  424. set(COMPONENT_LIB ${component_lib} PARENT_SCOPE)
  425. # COMPONENT_TARGET is deprecated but is made available with same function
  426. # as COMPONENT_LIB for compatibility.
  427. set(COMPONENT_TARGET ${component_lib} PARENT_SCOPE)
  428. __component_set_properties()
  429. endfunction()
  430. #
  431. # Deprecated functions
  432. #
  433. # register_component
  434. #
  435. # Compatibility function for registering 3.xx style components.
  436. macro(register_component)
  437. spaces2list(COMPONENT_SRCS)
  438. spaces2list(COMPONENT_SRCDIRS)
  439. spaces2list(COMPONENT_ADD_INCLUDEDIRS)
  440. spaces2list(COMPONENT_PRIV_INCLUDEDIRS)
  441. spaces2list(COMPONENT_REQUIRES)
  442. spaces2list(COMPONENT_PRIV_REQUIRES)
  443. spaces2list(COMPONENT_ADD_LDFRAGMENTS)
  444. spaces2list(COMPONENT_EMBED_FILES)
  445. spaces2list(COMPONENT_EMBED_TXTFILES)
  446. spaces2list(COMPONENT_SRCEXCLUDE)
  447. idf_component_register(SRCS "${COMPONENT_SRCS}"
  448. SRC_DIRS "${COMPONENT_SRCDIRS}"
  449. INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}"
  450. PRIV_INCLUDE_DIRS "${COMPONENT_PRIV_INCLUDEDIRS}"
  451. REQUIRES "${COMPONENT_REQUIRES}"
  452. PRIV_REQUIRES "${COMPONENT_PRIV_REQUIRES}"
  453. LDFRAGMENTS "${COMPONENT_ADD_LDFRAGMENTS}"
  454. EMBED_FILES "${COMPONENT_EMBED_FILES}"
  455. EMBED_TXTFILES "${COMPONENT_EMBED_TXTFILES}"
  456. EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}")
  457. endmacro()
  458. # require_idf_targets
  459. #
  460. # Compatibility function for requiring IDF build targets for 3.xx style components.
  461. function(require_idf_targets)
  462. set(__REQUIRED_IDF_TARGETS "${ARGN}")
  463. __component_check_target()
  464. endfunction()
  465. # register_config_only_component
  466. #
  467. # Compatibility function for registering 3.xx style config components.
  468. macro(register_config_only_component)
  469. register_component()
  470. endmacro()
  471. # component_compile_options
  472. #
  473. # Wrapper around target_compile_options that passes the component name
  474. function(component_compile_options)
  475. target_compile_options(${COMPONENT_LIB} PRIVATE ${ARGV})
  476. endfunction()
  477. # component_compile_definitions
  478. #
  479. # Wrapper around target_compile_definitions that passes the component name
  480. function(component_compile_definitions)
  481. target_compile_definitions(${COMPONENT_LIB} PRIVATE ${ARGV})
  482. endfunction()