CMakeLists.txt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. # esp_timer component was introduced in v4.2
  12. set(priv_requires driver)
  13. if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "4.1")
  14. list(APPEND priv_requires esp_timer)
  15. endif()
  16. idf_component_register(SRCS ${srcs}
  17. INCLUDE_DIRS include port
  18. PRIV_INCLUDE_DIRS private_include
  19. PRIV_REQUIRES ${priv_requires})
  20. set(target ${COMPONENT_LIB})
  21. component_compile_options(-Wstrict-prototypes)
  22. else()
  23. # Remove when dropping support for IDF 3.3
  24. set(COMPONENT_SRCS ${srcs})
  25. set(COMPONENT_ADD_INCLUDEDIRS include port)
  26. set(COMPONENT_PRIV_INCLUDEDIRS private_include)
  27. register_component()
  28. set(target ${COMPONENT_TARGET})
  29. endif()
  30. else()
  31. # Create traditional CMake target
  32. add_library(flasher ${srcs})
  33. target_include_directories(flasher PUBLIC include port PRIVATE private_include)
  34. if(PORT STREQUAL "STM32")
  35. target_link_libraries(flasher PUBLIC stm_cube)
  36. target_sources(flasher PRIVATE port/stm32_port.c)
  37. elseif(PORT STREQUAL "RASPBERRY_PI")
  38. find_library(pigpio_LIB pigpio)
  39. target_link_libraries(flasher PUBLIC ${pigpio_LIB})
  40. target_sources(flasher PRIVATE port/raspberry_port.c)
  41. else()
  42. message(FATAL_ERROR "Selected port is not supported")
  43. endif()
  44. set(target flasher)
  45. endif()
  46. if(DEFINED MD5_ENABLED OR CONFIG_SERIAL_FLASHER_MD5_ENABLED)
  47. target_compile_definitions(${target} PUBLIC -DMD5_ENABLED=1)
  48. endif()