CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. set(driver_components esp_eth esp_wifi openthread)
  7. # Check manually if the ESP_NETIF is configured in sdkconfig
  8. message(STATUS "Checking if sdkconfig contains CONFIG_TESTAPP_COMPONENT related config:")
  9. set(config_file "${CMAKE_CURRENT_SOURCE_DIR}/sdkconfig")
  10. if(EXISTS ${config_file})
  11. # If the config file exists, check for the non-default settings - LWIP
  12. # otherwise (file missing or defalut settings) go with ESP_NETIF
  13. file(READ ${config_file} config_file_content)
  14. string(FIND "${config_file_content}" "CONFIG_TESTAPP_COMPONENT_LWIP=y" match)
  15. if(NOT ${match} EQUAL -1)
  16. set(CONFIG_IS_LWIP 1)
  17. endif()
  18. endif()
  19. if(CONFIG_IS_LWIP)
  20. message(STATUS "CONFIG_TESTAPP_COMPONENT_ESP_LWIP")
  21. set(component_under_test lwip)
  22. set(expected_build_components lwip)
  23. else()
  24. message(STATUS "CONFIG_TESTAPP_COMPONENT_ESP_NETIF")
  25. set(component_under_test esp_netif)
  26. set(expected_build_components esp_netif lwip)
  27. endif()
  28. set(COMPONENTS ${component_under_test} main)
  29. include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  30. idf_build_set_property(__BUILD_COMPONENT_DEPGRAPH_ENABLED 1)
  31. project(network_components)
  32. # Get the actual build commponents included in the build
  33. idf_build_get_property(build_components BUILD_COMPONENTS)
  34. message(STATUS "Build components needed my main and ${component_under_test}:")
  35. foreach(comp ${build_components})
  36. message(STATUS "${comp}")
  37. endforeach()
  38. # Check for all driver components, these shall not be included
  39. foreach(comp ${driver_components})
  40. if(${comp} IN_LIST build_components)
  41. message(FATAL_ERROR "Component ${comp} shall not be included when building only ${component_under_test}")
  42. else()
  43. message(STATUS "-> OK: ${comp} is not included when building only ${component_under_test}")
  44. endif()
  45. endforeach()
  46. # Check for all needed components, these must be included
  47. foreach(comp ${expected_build_components})
  48. if(${comp} IN_LIST build_components)
  49. message(STATUS "-> OK: ${comp} is pulled by ${component_under_test}")
  50. else()
  51. message(FATAL_ERROR "${comp} is expected by adding ${component_under_test}")
  52. endif()
  53. endforeach()