CMakeLists.txt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. set(target ${COMPONENT_LIB})
  15. component_compile_options(-Wstrict-prototypes)
  16. else()
  17. # Remove when dropping support for IDF 3.3
  18. set(COMPONENT_SRCS ${srcs})
  19. set(COMPONENT_ADD_INCLUDEDIRS include port)
  20. set(COMPONENT_PRIV_INCLUDEDIRS private_include)
  21. register_component()
  22. set(target ${COMPONENT_TARGET})
  23. endif()
  24. else()
  25. # Create traditional CMake target
  26. add_library(flasher ${srcs})
  27. target_include_directories(flasher PUBLIC include port PRIVATE private_include)
  28. if(PORT STREQUAL "STM32")
  29. target_link_libraries(flasher PUBLIC stm_cube)
  30. target_sources(flasher PRIVATE port/stm32_port.c)
  31. elseif(PORT STREQUAL "RASPBERRY_PI")
  32. find_library(pigpio_LIB pigpio)
  33. target_link_libraries(flasher PUBLIC ${pigpio_LIB})
  34. target_sources(flasher PRIVATE port/raspberry_port.c)
  35. else()
  36. message(FATAL_ERROR "Selected port is not supported")
  37. endif()
  38. set(target flasher)
  39. endif()
  40. if(DEFINED MD5_ENABLED OR CONFIG_SERIAL_FLASHER_MD5_ENABLED)
  41. target_compile_definitions(${target} PUBLIC -DMD5_ENABLED=1)
  42. endif()