* Philosophical: "explicit is better than implicit".
* Practical: Allows useful errors if invalid directories given in components as the defaults aren't
always used. Also trims the -I path from a number of components that have no actual include
directory.
* Simplifies knowing which components will be header-only and which won't
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+
register_component()
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+
register_component()
if(${BOOTLOADER_BUILD})
set(COMPONENT_ADD_INCLUDEDIRS "include include_priv")
else()
+ set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_PRIV_INCLUDEDIRS "include_priv")
endif()
+set(COMPONENT_ADD_INCLUDEDIRS .)
set(COMPONENT_SRCDIRS linenoise argtable3 .)
+
register_component()
+set(COMPONENT_SRCDIRS ".")
register_component()
target_link_libraries(cxx stdc++)
-set(COMPONENT_PRIV_INCLUDEDIRS include/driver)
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+set(COMPONENT_PRIV_INCLUDEDIRS "include/driver")
register_component()
# Regular app build
set(COMPONENT_SRCDIRS ". hwcrypto")
+ set(COMPONENT_ADD_INCLUDEDIRS "include")
register_component()
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+
register_component()
set(COMPONENT_SRCDIRS . eth_phy)
+set(COMPONENT_ADD_INCLUDEDIRS "include")
register_component()
set(COMPONENT_ADD_INCLUDEDIRS port/include include/expat)
-
set(COMPONENT_SRCDIRS library port)
register_component()
+set(COMPONENT_SRCDIRS src)
set(COMPONENT_ADD_INCLUDEDIRS src)
-set(COMPONENT_SRCDIRS src/option src)
register_component()
set(COMPONENT_ADD_INCLUDEDIRS include)
set(COMPONENT_PRIV_INCLUDEDIRS include/freertos)
+set(COMPONENT_SRCDIRS ".")
register_component()
target_link_libraries(freertos "-Wl,--undefined=uxTopUsedPriority")
set(COMPONENT_SRCS ${COMPONENT_SRCS} multi_heap_poisoning.c)
endif()
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+
register_component()
if(CONFIG_HEAP_TRACING)
-# idf_test will be registered as an INTERFACE library (ie header paths only)
+set(COMPONENT_ADD_INCLUDEDIRS "include")
register_component()
-set(COMPONENT_SRCDIRS src)
+set(COMPONENT_SRCDIRS "src")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+
register_component()
-set(COMPONENT_SRCDIRS library port)
-set(COMPONENT_ADD_INCLUDEDIRS include port/include)
+set(COMPONENT_SRCDIRS cJSON)
+set(COMPONENT_ADD_INCLUDEDIRS cJSON)
register_component()
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
register_component()
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+set(COMPONENT_PRIV_INCLUDEDIRS "private_include")
register_component()
+set(COMPONENT_SRCDIRS ".")
set(COMPONENT_ADD_INCLUDEDIRS platform_include include)
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
-set(COMPONENT_ADD_INCLUDEDIRS include)
set(COMPONENT_SRCDIRS src)
+set(COMPONENT_ADD_INCLUDEDIRS include)
register_component()
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+
register_component()
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+
register_component()
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+
register_component()
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+
register_component()
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_PRIV_INCLUDEDIRS private_include)
register_component()
-set(COMPONENT_ADD_INCLUDEDIRS include port/include)
set(COMPONENT_SRCDIRS src/crypto port src/fast_crypto)
+set(COMPONENT_ADD_INCLUDEDIRS include port/include)
register_component()
+set(COMPONENT_SRCDIRS ".")
+set(COMPONENT_ADD_INCLUDEDIRS "include")
+
register_component()
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(CMAKE_TOOLCHAIN_FILE $ENV{IDF_PATH}/toolchain.cmake)
-project(idf_project ASM C CXX)
-include($ENV{IDF_PATH}/tools/cmake/project.cmake)
+project(subscribe_publish ASM C CXX)
+
+set(MAIN_SRCS main/subscribe_publish_sample.c)
-add_executable(subscribe_publish.elf
- main/subscribe_publish_sample.c)
+include($ENV{IDF_PATH}/tools/cmake/project.cmake)
+# Embed the certificate data directly in the built binary
target_add_binary_data(subscribe_publish.elf main/certs/aws-root-ca.pem TEXT)
target_add_binary_data(subscribe_publish.elf main/certs/certificate.pem.crt TEXT)
target_add_binary_data(subscribe_publish.elf main/certs/private.pem.key TEXT)
-
-# TODO: handle IDF_CI_BUILD dummy cert files here
-
-target_link_libraries(subscribe_publish.elf ${COMPONENT_LIBRARIES})
get_filename_component(component_dir ${CMAKE_CURRENT_LIST_FILE} DIRECTORY)
get_filename_component(component ${component_dir} NAME)
- if(NOT COMPONENT_SRCDIRS)
- set(COMPONENT_SRCDIRS ".")
- endif()
spaces2list(COMPONENT_SRCDIRS)
-
- if(NOT COMPONENT_ADD_INCLUDEDIRS)
- set(COMPONENT_ADD_INCLUDEDIRS "include")
- endif()
spaces2list(COMPONENT_ADD_INCLUDEDIRS)
- # if not explicit, build COMPONENT_SRCS by globbing in COMPONENT_SRCDIRS
+ # Add to COMPONENT_SRCS by globbing in COMPONENT_SRCDIRS
if(NOT COMPONENT_SRCS)
foreach(dir ${COMPONENT_SRCDIRS})
- get_filename_component(dir ${dir} ABSOLUTE BASE_DIR ${component_dir})
- file(GLOB matches "${dir}/*.[c|S]" "${dir}/*.cpp")
+ get_filename_component(abs_dir ${dir} ABSOLUTE BASE_DIR ${component_dir})
+ if(NOT IS_DIRECTORY ${abs_dir})
+ message(FATAL_ERROR "${CMAKE_CURRENT_LIST_FILE}: COMPONENT_SRCDIRS entry '${dir}' does not exist")
+ endif()
+
+ file(GLOB matches "${abs_dir}/*.[c|S]" "${abs_dir}/*.cpp")
if(matches)
list(SORT matches)
set(COMPONENT_SRCS "${COMPONENT_SRCS};${matches}")
+ else()
+ message(FATAL_ERROR "${CMAKE_CURRENT_LIST_FILE}: COMPONENT_SRCDIRS entry '${dir}' contains no source files")
endif(matches)
endforeach()
endif()
# add public includes
foreach(include_dir ${COMPONENT_ADD_INCLUDEDIRS})
- get_filename_component(include_dir ${include_dir} ABSOLUTE BASE_DIR ${component_dir})
- target_include_directories(${component} ${include_type} ${include_dir})
+ get_filename_component(abs_dir ${include_dir} ABSOLUTE BASE_DIR ${component_dir})
+ if(NOT IS_DIRECTORY ${abs_dir})
+ message(FATAL_ERROR "${CMAKE_CURRENT_LIST_FILE}: COMPONENT_ADD_INCLUDEDIRS entry '${include_dir}' does not exist")
+ endif()
+ target_include_directories(${component} ${include_type} ${abs_dir})
endforeach()
# add private includes
foreach(include_dir ${COMPONENT_PRIV_INCLUDEDIRS})
if (${include_type} STREQUAL INTERFACE)
- message(FATAL_ERROR "Component ${component} can't have no source files and COMPONENT_PRIV_INCLUDEDIRS set.")
+ message(FATAL_ERROR "${CMAKE_CURRENT_LIST_FILE} sets no component source files but sets COMPONENT_PRIV_INCLUDEDIRS")
+ endif()
+
+ get_filename_component(abs_dir ${include_dir} ABSOLUTE BASE_DIR ${component_dir})
+ if(NOT IS_DIRECTORY ${abs_dir})
+ message(FATAL_ERROR "${CMAKE_CURRENT_LIST_FILE}: COMPONENT_PRIV_INCLUDEDIRS entry '${niclude_dir}' does not exist")
endif()
- get_filename_component(include_dir ${include_dir} ABSOLUTE BASE_DIR ${component_dir})
- target_include_directories(${component} PRIVATE ${include_dir})
+ target_include_directories(${component} PRIVATE ${abs_dir})
endforeach()
endfunction(register_component)
#
function(lines2list variable_name)
string(REGEX REPLACE "\r?\n" ";" tmp "${${variable_name}}")
+ string(REGEX REPLACE ";;" ";" tmp "${tmp}")
set("${variable_name}" "${tmp}" PARENT_SCOPE)
endfunction()