CMakeLists.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. cmake_minimum_required(VERSION 3.5)
  2. if (DEFINED ESP_PLATFORM)
  3. # Register component to esp-idf build system
  4. set(COMPONENT_SRCS
  5. src/esp_loader.c
  6. src/esp_targets.c
  7. src/serial_comm.c
  8. src/md5_hash.c
  9. port/esp32_port.c)
  10. set(COMPONENT_ADD_INCLUDEDIRS "include port")
  11. set(COMPONENT_PRIV_INCLUDEDIRS "private_include" )
  12. register_component()
  13. component_compile_options(-Wstrict-prototypes)
  14. set(target ${COMPONENT_LIB})
  15. else()
  16. # Create traditional CMake target
  17. add_library(flasher
  18. src/esp_loader.c
  19. src/esp_targets.c
  20. src/serial_comm.c
  21. src/md5_hash.c)
  22. target_include_directories(flasher PUBLIC include port PRIVATE private_include)
  23. if(PORT STREQUAL "STM32")
  24. target_link_libraries(flasher PUBLIC stm_cube)
  25. target_sources(flasher PRIVATE port/stm32_port.c)
  26. elseif(PORT STREQUAL "RASPBERRY_PI")
  27. find_library(pigpio_LIB pigpio)
  28. target_link_libraries(flasher PUBLIC ${pigpio_LIB})
  29. target_sources(flasher PRIVATE port/raspberry_port.c)
  30. else()
  31. message(FATAL_ERROR "Selected port is not supported")
  32. endif()
  33. set(target flasher)
  34. endif()
  35. if(DEFINED MD5_ENABLED)
  36. target_compile_definitions(${target} PRIVATE -DMD5_ENABLED=${MD5_ENABLED})
  37. endif()