CMakeLists.txt 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. cmake_minimum_required(VERSION 3.5)
  2. set(srcs
  3. src/esp_loader.c
  4. src/esp_targets.c
  5. src/md5_hash.c
  6. src/protocol.c
  7. src/slip.c
  8. )
  9. if (DEFINED ESP_PLATFORM)
  10. # Register component to esp-idf build system
  11. list(APPEND srcs port/esp32_port.c)
  12. if ("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "4.0")
  13. # esp_timer component was introduced in v4.2
  14. set(priv_requires driver)
  15. if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "4.1")
  16. list(APPEND priv_requires esp_timer)
  17. endif()
  18. idf_component_register(SRCS ${srcs}
  19. INCLUDE_DIRS include port
  20. PRIV_INCLUDE_DIRS private_include
  21. PRIV_REQUIRES ${priv_requires})
  22. set(target ${COMPONENT_LIB})
  23. component_compile_options(-Wstrict-prototypes)
  24. else()
  25. # Remove when dropping support for IDF 3.3
  26. set(COMPONENT_SRCS ${srcs})
  27. set(COMPONENT_ADD_INCLUDEDIRS include port)
  28. set(COMPONENT_PRIV_INCLUDEDIRS private_include)
  29. register_component()
  30. set(target ${COMPONENT_TARGET})
  31. endif()
  32. else()
  33. # Create traditional CMake target
  34. add_library(flasher ${srcs})
  35. target_include_directories(flasher PUBLIC include port PRIVATE private_include)
  36. if(PORT STREQUAL "STM32")
  37. target_link_libraries(flasher PUBLIC stm_cube)
  38. target_sources(flasher PRIVATE port/stm32_port.c)
  39. elseif(PORT STREQUAL "RASPBERRY_PI")
  40. find_library(pigpio_LIB pigpio)
  41. target_link_libraries(flasher PUBLIC ${pigpio_LIB})
  42. target_sources(flasher PRIVATE port/raspberry_port.c)
  43. else()
  44. message(FATAL_ERROR "Selected port is not supported")
  45. endif()
  46. set(target flasher)
  47. endif()
  48. if(DEFINED MD5_ENABLED OR CONFIG_SERIAL_FLASHER_MD5_ENABLED)
  49. target_compile_definitions(${target} PUBLIC -DMD5_ENABLED=1)
  50. endif()
  51. if(DEFINED CONFIG_SERIAL_FLASHER_RESET_HOLD_TIME_MS AND DEFINED CONFIG_SERIAL_FLASHER_BOOT_HOLD_TIME_MS)
  52. target_compile_definitions(${target}
  53. PUBLIC
  54. SERIAL_FLASHER_RESET_HOLD_TIME_MS=${CONFIG_SERIAL_FLASHER_RESET_HOLD_TIME_MS}
  55. SERIAL_FLASHER_BOOT_HOLD_TIME_MS=${CONFIG_SERIAL_FLASHER_BOOT_HOLD_TIME_MS}
  56. )
  57. else()
  58. if(NOT DEFINED SERIAL_FLASHER_RESET_HOLD_TIME_MS)
  59. target_compile_definitions(${target}
  60. PUBLIC
  61. SERIAL_FLASHER_RESET_HOLD_TIME_MS=100
  62. )
  63. endif()
  64. if(NOT DEFINED SERIAL_FLASHER_BOOT_HOLD_TIME_MS)
  65. target_compile_definitions(${target}
  66. PUBLIC
  67. SERIAL_FLASHER_BOOT_HOLD_TIME_MS=50
  68. )
  69. endif()
  70. endif()