Merge branch 'bugfix/misc_cmake_changes' into 'master'

Follow up CMake changes/fixes

See merge request idf/esp-idf!5267
This commit is contained in:
Angus Gratton
2019-06-21 13:27:55 +08:00
7 changed files with 52 additions and 23 deletions

View File

@@ -163,12 +163,14 @@ endfunction()
# idf_build_component
#
# @brief Specify component directory for the build system to process.
# @brief Present a directory that contains a component to the build system.
# Relative paths are converted to absolute paths with respect to current directory.
# Any component that needs to be processed has to be specified using this
# command before calling idf_build_process.
# All calls to this command must be performed before idf_build_process.
#
# @param[in] component_dir directory of the component to process
# @note This command does not guarantee that the component will be processed
# during build (see the COMPONENTS argument description for command idf_build_process)
#
# @param[in] component_dir directory of the component
function(idf_build_component component_dir)
idf_build_get_property(prefix __PREFIX)
__component_add(${component_dir} ${prefix} 0)
@@ -335,7 +337,16 @@ endfunction()
# @param[in, optional] SDKCONFIG_DEFAULTS (single value) config defaults file to use for the build; defaults
# to none (Kconfig defaults or previously generated config are used)
# @param[in, optional] BUILD_DIR (single value) directory for build artifacts; defautls to CMAKE_BINARY_DIR
# @param[in, optional] COMPONENTS (multivalue) starting components for trimming build
# @param[in, optional] COMPONENTS (multivalue) select components to process among the components
# known by the build system
# (added via `idf_build_component`). This argument is used to trim the build.
# Other components are automatically added if they are required
# in the dependency chain, i.e.
# the public and private requirements of the components in this list
# are automatically added, and in
# turn the public and private requirements of those requirements,
# so on and so forth. If not specified, all components known to the build system
# are processed.
macro(idf_build_process target)
set(options)
set(single_value PROJECT_DIR PROJECT_VER PROJECT_NAME BUILD_DIR SDKCONFIG SDKCONFIG_DEFAULTS)
@@ -367,15 +378,20 @@ macro(idf_build_process target)
__build_check_python()
idf_build_set_property(__COMPONENT_REQUIRES_COMMON ${target} APPEND)
__component_get_requirements()
# Perform early expansion of component CMakeLists.txt in CMake scripting mode.
# It is here we retrieve the public and private requirements of each component.
# It is also here we add the common component requirements to each component's
# own requirements.
__component_get_requirements()
idf_build_get_property(component_targets __COMPONENT_TARGETS)
# Finally, do component expansion. In this case it simply means getting a final list
# of build component targets given the requirements set by each component.
# Check if we need to trim the components first, and build initial components list
# from that.
if(__COMPONENTS)
unset(component_targets)
foreach(component ${__COMPONENTS})
@@ -390,7 +406,7 @@ macro(idf_build_process target)
foreach(component_target ${component_targets})
__build_expand_requirements(${component_target})
endforeach()
unset(__COMPONENT_TARGETS_SEEN)
idf_build_unset_property(__COMPONENT_TARGETS_SEEN)
# Get a list of common component requirements in component targets form (previously
# we just have a list of component names)

View File

@@ -427,8 +427,7 @@ function(idf_component_register)
list(REMOVE_ITEM common_reqs ${component_lib})
link_libraries(${common_reqs})
idf_build_get_property(sdkconfig_h SDKCONFIG_HEADER)
get_filename_component(sdkconfig_h ${sdkconfig_h} DIRECTORY)
idf_build_get_property(config_dir CONFIG_DIR)
# The contents of 'sources' is from the __component_add_sources call
if(sources OR __EMBED_FILES OR __EMBED_TXTFILES)
@@ -436,14 +435,14 @@ function(idf_component_register)
__component_set_property(${component_target} COMPONENT_TYPE LIBRARY)
target_include_directories(${component_lib} PUBLIC ${__INCLUDE_DIRS})
target_include_directories(${component_lib} PRIVATE ${__PRIV_INCLUDE_DIRS})
target_include_directories(${component_lib} PUBLIC ${sdkconfig_h})
target_include_directories(${component_lib} PUBLIC ${config_dir})
set_target_properties(${component_lib} PROPERTIES OUTPUT_NAME ${COMPONENT_NAME})
__ldgen_add_component(${component_lib})
else()
add_library(${component_lib} INTERFACE)
__component_set_property(${component_target} COMPONENT_TYPE CONFIG_ONLY)
target_include_directories(${component_lib} INTERFACE ${__INCLUDE_DIRS})
target_include_directories(${component_lib} INTERFACE ${sdkconfig_h})
target_include_directories(${component_lib} INTERFACE ${config_dir})
endif()
# Alias the static/interface library created for linking to external targets.

View File

@@ -189,6 +189,7 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults)
idf_build_set_property(SDKCONFIG_JSON ${sdkconfig_json})
idf_build_set_property(SDKCONFIG_CMAKE ${sdkconfig_cmake})
idf_build_set_property(SDKCONFIG_JSON_MENUS ${sdkconfig_json_menus})
idf_build_set_property(CONFIG_DIR ${config_dir})
idf_build_get_property(menuconfig_depends __MENUCONFIG_DEPENDS)
@@ -204,6 +205,7 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults)
"COMPONENT_KCONFIGS_PROJBUILD=${kconfig_projbuilds}"
"IDF_CMAKE=y"
"KCONFIG_CONFIG=${sdkconfig}"
"IDF_TARGET=${idf_target}"
${mconf} ${root_kconfig}
# VERBATIM cannot be used here because it cannot handle ${mconf}="winpty mconf-idf" and the escaping must be
# done manually