CMakeLists.txt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. cmake_minimum_required(VERSION 3.5)
  2. set(srcs src/esp_loader.c
  3. src/esp_targets.c
  4. src/serial_comm.c
  5. src/md5_hash.c
  6. )
  7. if (DEFINED ESP_PLATFORM)
  8. # Register component to esp-idf build system
  9. list(APPEND srcs port/esp32_port.c)
  10. if ("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "4.0")
  11. idf_component_register(SRCS ${srcs}
  12. INCLUDE_DIRS include port
  13. PRIV_INCLUDE_DIRS private_include
  14. PRIV_REQUIRES driver)
  15. set(target ${COMPONENT_LIB})
  16. component_compile_options(-Wstrict-prototypes)
  17. else()
  18. # Remove when dropping support for IDF 3.3
  19. set(COMPONENT_SRCS ${srcs})
  20. set(COMPONENT_ADD_INCLUDEDIRS include port)
  21. set(COMPONENT_PRIV_INCLUDEDIRS private_include)
  22. register_component()
  23. set(target ${COMPONENT_TARGET})
  24. endif()
  25. else()
  26. # Create traditional CMake target
  27. add_library(flasher ${srcs})
  28. target_include_directories(flasher PUBLIC include port PRIVATE private_include)
  29. if(PORT STREQUAL "STM32")
  30. target_link_libraries(flasher PUBLIC stm_cube)
  31. target_sources(flasher PRIVATE port/stm32_port.c)
  32. elseif(PORT STREQUAL "RASPBERRY_PI")
  33. find_library(pigpio_LIB pigpio)
  34. target_link_libraries(flasher PUBLIC ${pigpio_LIB})
  35. target_sources(flasher PRIVATE port/raspberry_port.c)
  36. else()
  37. message(FATAL_ERROR "Selected port is not supported")
  38. endif()
  39. set(target flasher)
  40. endif()
  41. if(DEFINED MD5_ENABLED OR CONFIG_SERIAL_FLASHER_MD5_ENABLED)
  42. target_compile_definitions(${target} PUBLIC -DMD5_ENABLED=1)
  43. endif()