CMakeLists.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # 1. Load all source files from lib/ and src/
  2. file(GLOB_RECURSE LIB_SRCS "lib/*.cpp" "lib/*.c")
  3. file(GLOB_RECURSE SRC_SRCS "src/*.cpp" "src/*.c")
  4. # 2. Search for headers from lib/, include/ and src/
  5. file(GLOB_RECURSE ALL_HEADERS
  6. "lib/*.h" "lib/*.hpp"
  7. "include/*.h" "include/*.hpp"
  8. "src/*.h" "src/*.hpp"
  9. )
  10. # 3. Add include directories
  11. set(ALL_INC_DIRS "")
  12. # Add root directories
  13. list(APPEND ALL_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include")
  14. list(APPEND ALL_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
  15. list(APPEND ALL_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/lib")
  16. foreach(header ${ALL_HEADERS})
  17. # Search all found headers and add their directories
  18. get_filename_component(header_dir ${header} DIRECTORY)
  19. list(APPEND ALL_INC_DIRS ${header_dir})
  20. # PlatformIO trick: add parent diewcoty for relations like "Folder/File.h"
  21. get_filename_component(parent_dir ${header_dir} DIRECTORY)
  22. list(APPEND ALL_INC_DIRS ${parent_dir})
  23. endforeach()
  24. list(REMOVE_DUPLICATES ALL_INC_DIRS)
  25. # 4. Register component for ESP-IDF
  26. idf_component_register(
  27. PRIV_REQUIRES
  28. spi_flash
  29. SRCS
  30. ${SRC_SRCS}
  31. ${LIB_SRCS}
  32. INCLUDE_DIRS
  33. ${ALL_INC_DIRS}
  34. REQUIRES
  35. arduino
  36. )
  37. add_compile_definitions(
  38. NBUS_NODE_TYPE_SLAVE
  39. ARDUINO_CORE_3X
  40. )