CMakeLists.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. cmake_minimum_required(VERSION 3.5)
  2. project(esp-idf C CXX ASM)
  3. #
  4. # Add each component to the build as a library
  5. #
  6. foreach(COMPONENT_PATH ${BUILD_COMPONENT_PATHS})
  7. get_filename_component(COMPONENT_NAME ${COMPONENT_PATH} NAME)
  8. list(FIND BUILD_TEST_COMPONENT_PATHS ${COMPONENT_PATH} idx)
  9. if(NOT idx EQUAL -1)
  10. list(GET BUILD_TEST_COMPONENTS ${idx} test_component)
  11. set(COMPONENT_NAME ${test_component})
  12. endif()
  13. component_get_target(COMPONENT_TARGET ${COMPONENT_NAME})
  14. add_subdirectory(${COMPONENT_PATH} ${COMPONENT_NAME})
  15. endforeach()
  16. unset(COMPONENT_NAME)
  17. unset(COMPONENT_PATH)
  18. # each component should see the include directories of its requirements
  19. #
  20. # (we can't do this until all components are registered and targets exist in cmake, as we have
  21. # a circular requirements graph...)
  22. foreach(component ${BUILD_COMPONENTS})
  23. component_get_target(component_target ${component})
  24. if(TARGET ${component_target})
  25. get_component_requirements(${component} deps priv_deps)
  26. list(APPEND priv_deps ${IDF_COMPONENT_REQUIRES_COMMON})
  27. foreach(dep ${deps})
  28. component_get_target(dep_target ${dep})
  29. add_component_dependencies(${component_target} ${dep_target} PUBLIC)
  30. endforeach()
  31. foreach(dep ${priv_deps})
  32. component_get_target(dep_target ${dep})
  33. add_component_dependencies(${component_target} ${dep_target} PRIVATE)
  34. endforeach()
  35. endif()
  36. endforeach()