mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 03:07:21 +02:00
cmake: check include directories
This commit is contained in:
@ -233,10 +233,10 @@ function(__component_get_requirements)
|
|||||||
file(REMOVE ${component_requires_file})
|
file(REMOVE ${component_requires_file})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# __component_add_sources, __component_check_target
|
# __component_add_sources, __component_check_target, __component_add_include_dirs
|
||||||
#
|
#
|
||||||
# Utility macros for component registration. Adds source files and checks target requirements
|
# Utility macros for component registration. Adds source files and checks target requirements,
|
||||||
# respectively.
|
# and adds include directories respectively.
|
||||||
macro(__component_add_sources sources)
|
macro(__component_add_sources sources)
|
||||||
set(sources "")
|
set(sources "")
|
||||||
if(__SRCS)
|
if(__SRCS)
|
||||||
@ -280,6 +280,16 @@ macro(__component_add_sources sources)
|
|||||||
list(REMOVE_DUPLICATES sources)
|
list(REMOVE_DUPLICATES sources)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
macro(__component_add_include_dirs lib dirs type)
|
||||||
|
foreach(dir ${dirs})
|
||||||
|
get_filename_component(_dir ${dir} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
if(NOT IS_DIRECTORY ${_dir})
|
||||||
|
message(FATAL_ERROR "Include directory '${_dir}' is not a directory.")
|
||||||
|
endif()
|
||||||
|
target_include_directories(${lib} ${type} ${_dir})
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
macro(__component_check_target)
|
macro(__component_check_target)
|
||||||
if(__REQUIRED_IDF_TARGETS)
|
if(__REQUIRED_IDF_TARGETS)
|
||||||
idf_build_get_property(idf_target IDF_TARGET)
|
idf_build_get_property(idf_target IDF_TARGET)
|
||||||
@ -325,6 +335,7 @@ macro(__component_set_all_dependencies)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
# idf_component_get_property
|
# idf_component_get_property
|
||||||
#
|
#
|
||||||
# @brief Retrieve the value of the specified component property
|
# @brief Retrieve the value of the specified component property
|
||||||
@ -437,16 +448,16 @@ function(idf_component_register)
|
|||||||
if(sources OR __EMBED_FILES OR __EMBED_TXTFILES)
|
if(sources OR __EMBED_FILES OR __EMBED_TXTFILES)
|
||||||
add_library(${component_lib} STATIC ${sources})
|
add_library(${component_lib} STATIC ${sources})
|
||||||
__component_set_property(${component_target} COMPONENT_TYPE LIBRARY)
|
__component_set_property(${component_target} COMPONENT_TYPE LIBRARY)
|
||||||
target_include_directories(${component_lib} PUBLIC ${__INCLUDE_DIRS})
|
__component_add_include_dirs(${component_lib} "${__INCLUDE_DIRS}" PUBLIC)
|
||||||
target_include_directories(${component_lib} PRIVATE ${__PRIV_INCLUDE_DIRS})
|
__component_add_include_dirs(${component_lib} "${__PRIV_INCLUDE_DIRS}" PRIVATE)
|
||||||
target_include_directories(${component_lib} PUBLIC ${config_dir})
|
__component_add_include_dirs(${component_lib} "${config_dir}" PUBLIC)
|
||||||
set_target_properties(${component_lib} PROPERTIES OUTPUT_NAME ${COMPONENT_NAME})
|
set_target_properties(${component_lib} PROPERTIES OUTPUT_NAME ${COMPONENT_NAME})
|
||||||
__ldgen_add_component(${component_lib})
|
__ldgen_add_component(${component_lib})
|
||||||
else()
|
else()
|
||||||
add_library(${component_lib} INTERFACE)
|
add_library(${component_lib} INTERFACE)
|
||||||
__component_set_property(${component_target} COMPONENT_TYPE CONFIG_ONLY)
|
__component_set_property(${component_target} COMPONENT_TYPE CONFIG_ONLY)
|
||||||
target_include_directories(${component_lib} INTERFACE ${__INCLUDE_DIRS})
|
__component_add_include_dirs(${component_lib} "${__INCLUDE_DIRS}" INTERFACE)
|
||||||
target_include_directories(${component_lib} INTERFACE ${config_dir})
|
__component_add_include_dirs(${component_lib} "${config_dir}" INTERFACE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Alias the static/interface library created for linking to external targets.
|
# Alias the static/interface library created for linking to external targets.
|
||||||
|
Reference in New Issue
Block a user