Merge branch 'bugfix/cmake_component_names' into 'master'

CMake: Component name related bugfixes

See merge request espressif/esp-idf!5921
pull/2446/head^2
Angus Gratton 2019-09-17 11:16:25 +08:00
commit 96b96ae244
4 zmienionych plików z 28 dodań i 14 usunięć

Wyświetl plik

@ -1130,7 +1130,8 @@ For example, to get the Python interpreter used for the build:
message(STATUS "The Python intepreter is: ${python}")
- BUILD_DIR - build directory; set from ``idf_build_process`` BUILD_DIR argument
- BUILD_COMPONENTS - list of components (more specifically, component aliases) included in the build; set by ``idf_build_process``
- BUILD_COMPONENTS - list of components included in the build; set by ``idf_build_process``
- BUILD_COMPONENT_ALIASES - list of library alias of components included in the build; set by ``idf_build_process``
- C_COMPILE_OPTIONS - compile options applied to all components' C source files
- COMPILE_OPTIONS - compile options applied to all components' source files, regardless of it being C or C++
- COMPILE_DEFINITIONS - compile definitions applied to all component source files

Wyświetl plik

@ -220,6 +220,24 @@ function(__build_expand_requirements component_target)
idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)
if(NOT component_target IN_LIST build_component_targets)
idf_build_set_property(__BUILD_COMPONENT_TARGETS ${component_target} APPEND)
__component_get_property(component_lib ${component_target} COMPONENT_LIB)
idf_build_set_property(__BUILD_COMPONENTS ${component_lib} APPEND)
idf_build_get_property(prefix __PREFIX)
__component_get_property(component_prefix ${component_target} __PREFIX)
__component_get_property(component_alias ${component_target} COMPONENT_ALIAS)
idf_build_set_property(BUILD_COMPONENT_ALIASES ${component_alias} APPEND)
# Only put in the prefix in the name if it is not the default one
if(component_prefix STREQUAL prefix)
__component_get_property(component_name ${component_target} COMPONENT_NAME)
idf_build_set_property(BUILD_COMPONENTS ${component_name} APPEND)
else()
idf_build_set_property(BUILD_COMPONENTS ${component_alias} APPEND)
endif()
endif()
endfunction()

Wyświetl plik

@ -56,13 +56,8 @@ function(__component_get_target var name_or_alias)
foreach(component_target ${component_targets})
__component_get_property(_component_name ${component_target} COMPONENT_NAME)
if(name_or_alias STREQUAL _component_name)
# There should only be one component of the same name
if(NOT target)
set(target ${component_target})
else()
message(FATAL_ERROR "Multiple components with name '${name_or_alias}' found.")
return()
endif()
set(target ${component_target})
break()
endif()
endforeach()
set(${var} ${target} PARENT_SCOPE)
@ -191,6 +186,7 @@ function(__component_add component_dir prefix)
__component_set_property(${component_target} COMPONENT_NAME ${component_name})
__component_set_property(${component_target} COMPONENT_DIR ${component_dir})
__component_set_property(${component_target} COMPONENT_ALIAS ${component_alias})
__component_set_property(${component_target} __PREFIX ${prefix})
# Set Kconfig related properties on the component
@ -482,10 +478,6 @@ function(idf_component_register)
# Set dependencies
__component_set_all_dependencies()
# Add the component to built components
idf_build_set_property(__BUILD_COMPONENTS ${component_lib} APPEND)
idf_build_set_property(BUILD_COMPONENTS ${component_alias} APPEND)
# Make the COMPONENT_LIB variable available in the component CMakeLists.txt
set(COMPONENT_LIB ${component_lib} PARENT_SCOPE)
# COMPONENT_TARGET is deprecated but is made available with same function

Wyświetl plik

@ -353,13 +353,16 @@ macro(project project_name)
# so that it treats components equally.
#
# This behavior should only be when user did not set REQUIRES/PRIV_REQUIRES manually.
idf_build_get_property(build_components BUILD_COMPONENTS)
idf_build_get_property(build_components BUILD_COMPONENT_ALIASES)
if(idf::main IN_LIST build_components)
__component_get_target(main_target idf::main)
__component_get_property(reqs ${main_target} REQUIRES)
__component_get_property(priv_reqs ${main_target} PRIV_REQUIRES)
idf_build_get_property(common_reqs __COMPONENT_REQUIRES_COMMON)
if(reqs STREQUAL common_reqs AND NOT priv_reqs) #if user has not set any requirements
if(test_components)
list(REMOVE_ITEM build_components ${test_components})
endif()
list(REMOVE_ITEM build_components idf::main)
__component_get_property(lib ${main_target} COMPONENT_LIB)
set_property(TARGET ${lib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${build_components}")
@ -392,7 +395,7 @@ macro(project project_name)
target_link_libraries(${project_elf} "-Wl,--no-whole-archive")
endif()
idf_build_get_property(build_components BUILD_COMPONENTS)
idf_build_get_property(build_components BUILD_COMPONENT_ALIASES)
if(test_components)
list(REMOVE_ITEM build_components ${test_components})
endif()