| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- # 1. Load all source files from lib/ and src/
- file(GLOB_RECURSE LIB_SRCS "lib/*.cpp" "lib/*.c")
- file(GLOB_RECURSE SRC_SRCS "src/*.cpp" "src/*.c")
- # 2. Search for headers from lib/, include/ and src/
- file(GLOB_RECURSE ALL_HEADERS
- "lib/*.h" "lib/*.hpp"
- "include/*.h" "include/*.hpp"
- "src/*.h" "src/*.hpp"
- )
- # 3. Add include directories
- set(ALL_INC_DIRS "")
- # Add root directories
- list(APPEND ALL_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include")
- list(APPEND ALL_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
- list(APPEND ALL_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/lib")
- foreach(header ${ALL_HEADERS})
- # Search all found headers and add their directories
- get_filename_component(header_dir ${header} DIRECTORY)
- list(APPEND ALL_INC_DIRS ${header_dir})
-
- # PlatformIO trick: add parent diewcoty for relations like "Folder/File.h"
- get_filename_component(parent_dir ${header_dir} DIRECTORY)
- list(APPEND ALL_INC_DIRS ${parent_dir})
- endforeach()
- list(REMOVE_DUPLICATES ALL_INC_DIRS)
- # 4. Register component for ESP-IDF
- idf_component_register(
- PRIV_REQUIRES
- spi_flash
- SRCS
- ${SRC_SRCS}
- ${LIB_SRCS}
- INCLUDE_DIRS
- ${ALL_INC_DIRS}
- REQUIRES
- arduino
- )
|