CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. idf_build_get_property(target IDF_TARGET)
  2. if(${target} STREQUAL "linux")
  3. return() # This component is not supported by the POSIX/Linux simulator
  4. endif()
  5. idf_build_get_property(components_to_build BUILD_COMPONENTS)
  6. set(srcs)
  7. set(include)
  8. set(ld_fragments linker.lf)
  9. # As CONFIG_ETH_ENABLED comes from Kconfig, it is not evaluated yet
  10. # when components are being registered.
  11. # Thus, always add the (private) requirements, regardless of Kconfig
  12. set(priv_requires driver log esp_timer)
  13. # If Ethernet disabled in Kconfig, this is a config-only component
  14. if(CONFIG_ETH_ENABLED)
  15. set(srcs "src/esp_eth.c" "src/esp_eth_phy_802_3.c")
  16. set(include "include")
  17. if(NOT CMAKE_BUILD_EARLY_EXPANSION)
  18. # esp_netif related
  19. if(esp_netif IN_LIST components_to_build)
  20. list(APPEND srcs "src/esp_eth_netif_glue.c")
  21. endif()
  22. endif()
  23. if(CONFIG_ETH_USE_ESP32_EMAC)
  24. list(APPEND srcs "src/esp_eth_mac_esp.c"
  25. "src/esp_eth_phy_dp83848.c"
  26. "src/esp_eth_phy_ip101.c"
  27. "src/esp_eth_phy_ksz80xx.c"
  28. "src/esp_eth_phy_lan87xx.c"
  29. "src/esp_eth_phy_rtl8201.c")
  30. endif()
  31. if(CONFIG_ETH_SPI_ETHERNET_DM9051)
  32. list(APPEND srcs "src/esp_eth_mac_dm9051.c"
  33. "src/esp_eth_phy_dm9051.c")
  34. endif()
  35. if(CONFIG_ETH_SPI_ETHERNET_W5500)
  36. list(APPEND srcs "src/esp_eth_mac_w5500.c"
  37. "src/esp_eth_phy_w5500.c")
  38. endif()
  39. if(CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL)
  40. list(APPEND srcs "src/esp_eth_mac_ksz8851snl.c"
  41. "src/esp_eth_phy_ksz8851snl.c")
  42. endif()
  43. if(CONFIG_ETH_USE_OPENETH)
  44. list(APPEND srcs "src/esp_eth_mac_openeth.c"
  45. "src/esp_eth_phy_dp83848.c")
  46. endif()
  47. endif()
  48. idf_component_register(SRCS "${srcs}"
  49. INCLUDE_DIRS ${include}
  50. LDFRAGMENTS ${ld_fragments}
  51. REQUIRES esp_event # For using "ESP_EVENT_DECLARE_BASE" in header file
  52. PRIV_REQUIRES ${priv_requires})
  53. if(CONFIG_ETH_ENABLED)
  54. target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
  55. endif()
  56. if(CONFIG_ETH_ENABLED)
  57. if(CONFIG_ETH_USE_SPI_ETHERNET)
  58. idf_component_optional_requires(PUBLIC driver esp_driver_gpio)
  59. endif()
  60. idf_component_optional_requires(PRIVATE esp_netif esp_pm)
  61. endif()