CMakeLists.txt 1.5 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 src/esp_loader.c src/serial_comm.c src/md5_hash.c port/esp32_port.c)
  5. set(COMPONENT_ADD_INCLUDEDIRS "include")
  6. set(COMPONENT_PRIV_INCLUDEDIRS "private_include" )
  7. register_component()
  8. component_compile_options(-Wstrict-prototypes)
  9. set(target ${COMPONENT_LIB})
  10. else()
  11. # Create traditional CMake target
  12. add_library(flasher src/esp_loader.c src/serial_comm.c src/md5_hash.c)
  13. target_include_directories(flasher PUBLIC include PRIVATE private_include)
  14. if(PORT STREQUAL "STM32")
  15. target_link_libraries(flasher PUBLIC stm_cube)
  16. target_sources(flasher PRIVATE port/stm32_port.c)
  17. elseif(PORT STREQUAL "RASPBERRY_PI")
  18. find_library(pigpio_LIB pigpio)
  19. target_link_libraries(flasher PUBLIC ${pigpio_LIB})
  20. target_sources(flasher PRIVATE port/raspberry_port.c)
  21. else()
  22. message(FATAL_ERROR "Selected port is not supported")
  23. endif()
  24. set(target flasher)
  25. endif()
  26. if(TARGET_SOC STREQUAL "ESP32")
  27. target_compile_definitions(${target} PUBLIC -DTARGET_ESP32)
  28. elseif(TARGET_SOC STREQUAL "ESP32_S2")
  29. target_compile_definitions(${target} PUBLIC -DTARGET_ESP32_S2)
  30. elseif(TARGET_SOC STREQUAL "ESP8266")
  31. target_compile_definitions(${target} PUBLIC -DTARGET_ESP8266)
  32. endif()
  33. if(DEFINED MD5_ENABLED)
  34. target_compile_definitions(${target} PUBLIC -DMD5_ENABLED=${MD5_ENABLED})
  35. endif()