mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
cmake: fix scope issues
This commit is contained in:
parent
477fa49fc0
commit
de9bb5a160
@ -1,21 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
project(esp-idf C CXX ASM)
|
project(esp-idf C CXX ASM)
|
||||||
|
|
||||||
# Include the sdkconfig cmake file, since the following operations require
|
|
||||||
# knowledge of config values.
|
|
||||||
idf_build_get_property(sdkconfig_cmake SDKCONFIG_CMAKE)
|
|
||||||
include(${sdkconfig_cmake})
|
|
||||||
|
|
||||||
# Make each build property available as a read-only variable
|
|
||||||
idf_build_get_property(build_properties __BUILD_PROPERTIES)
|
|
||||||
foreach(build_property ${build_properties})
|
|
||||||
idf_build_get_property(val ${build_property})
|
|
||||||
set(${build_property} "${val}")
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Check that the CMake target value matches the Kconfig target value.
|
|
||||||
__target_check()
|
|
||||||
|
|
||||||
unset(compile_options)
|
unset(compile_options)
|
||||||
unset(c_compile_options)
|
unset(c_compile_options)
|
||||||
unset(cxx_compile_options)
|
unset(cxx_compile_options)
|
||||||
@ -88,19 +73,6 @@ idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
|
|||||||
|
|
||||||
idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)
|
idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)
|
||||||
|
|
||||||
# Include each component's project_include.cmake
|
|
||||||
foreach(component_target ${build_component_targets})
|
|
||||||
__component_get_property(dir ${component_target} COMPONENT_DIR)
|
|
||||||
__component_get_property(_name ${component_target} COMPONENT_NAME)
|
|
||||||
set(COMPONENT_NAME ${_name})
|
|
||||||
set(COMPONENT_DIR ${dir})
|
|
||||||
set(COMPONENT_PATH ${dir}) # this is deprecated, users are encouraged to use COMPONENT_DIR;
|
|
||||||
# retained for compatibility
|
|
||||||
if(EXISTS ${COMPONENT_DIR}/project_include.cmake)
|
|
||||||
include(${COMPONENT_DIR}/project_include.cmake)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Add each component as a subdirectory, processing each component's CMakeLists.txt
|
# Add each component as a subdirectory, processing each component's CMakeLists.txt
|
||||||
foreach(component_target ${build_component_targets})
|
foreach(component_target ${build_component_targets})
|
||||||
__component_get_property(dir ${component_target} COMPONENT_DIR)
|
__component_get_property(dir ${component_target} COMPONENT_DIR)
|
||||||
@ -146,5 +118,3 @@ foreach(build_component ${build_components})
|
|||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,6 +248,41 @@ function(__build_check_python)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Prepare for component processing expanding each component's project include
|
||||||
|
#
|
||||||
|
macro(__build_process_project_includes)
|
||||||
|
# Include the sdkconfig cmake file, since the following operations require
|
||||||
|
# knowledge of config values.
|
||||||
|
idf_build_get_property(sdkconfig_cmake SDKCONFIG_CMAKE)
|
||||||
|
include(${sdkconfig_cmake})
|
||||||
|
|
||||||
|
# Make each build property available as a read-only variable
|
||||||
|
idf_build_get_property(build_properties __BUILD_PROPERTIES)
|
||||||
|
foreach(build_property ${build_properties})
|
||||||
|
idf_build_get_property(val ${build_property})
|
||||||
|
set(${build_property} "${val}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Check that the CMake target value matches the Kconfig target value.
|
||||||
|
__target_check()
|
||||||
|
|
||||||
|
idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)
|
||||||
|
|
||||||
|
# Include each component's project_include.cmake
|
||||||
|
foreach(component_target ${build_component_targets})
|
||||||
|
__component_get_property(dir ${component_target} COMPONENT_DIR)
|
||||||
|
__component_get_property(_name ${component_target} COMPONENT_NAME)
|
||||||
|
set(COMPONENT_NAME ${_name})
|
||||||
|
set(COMPONENT_DIR ${dir})
|
||||||
|
set(COMPONENT_PATH ${dir}) # this is deprecated, users are encouraged to use COMPONENT_DIR;
|
||||||
|
# retained for compatibility
|
||||||
|
if(EXISTS ${COMPONENT_DIR}/project_include.cmake)
|
||||||
|
include(${COMPONENT_DIR}/project_include.cmake)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Utility macro for setting default property value if argument is not specified
|
# Utility macro for setting default property value if argument is not specified
|
||||||
# for idf_build_process().
|
# for idf_build_process().
|
||||||
@ -280,7 +315,7 @@ endmacro()
|
|||||||
# to none (Kconfig defaults or previously generated config are used)
|
# 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] 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) starting components for trimming build
|
||||||
function(idf_build_process target)
|
macro(idf_build_process target)
|
||||||
set(options)
|
set(options)
|
||||||
set(single_value PROJECT_DIR PROJECT_VER PROJECT_NAME BUILD_DIR SDKCONFIG SDKCONFIG_DEFAULTS)
|
set(single_value PROJECT_DIR PROJECT_VER PROJECT_NAME BUILD_DIR SDKCONFIG SDKCONFIG_DEFAULTS)
|
||||||
set(multi_value COMPONENTS)
|
set(multi_value COMPONENTS)
|
||||||
@ -291,7 +326,7 @@ function(idf_build_process target)
|
|||||||
# Check build target is specified. Since this target corresponds to a component
|
# Check build target is specified. Since this target corresponds to a component
|
||||||
# name, the target component is automatically added to the list of common component
|
# name, the target component is automatically added to the list of common component
|
||||||
# requirements.
|
# requirements.
|
||||||
if(NOT target OR target STREQUAL "")
|
if(target STREQUAL "")
|
||||||
message(FATAL_ERROR "Build target not specified.")
|
message(FATAL_ERROR "Build target not specified.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -386,11 +421,13 @@ function(idf_build_process target)
|
|||||||
idf_build_set_property(___COMPONENT_REQUIRES_COMMON ${lib} APPEND)
|
idf_build_set_property(___COMPONENT_REQUIRES_COMMON ${lib} APPEND)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
__build_process_project_includes()
|
||||||
|
|
||||||
# Perform component processing (inclusion of project_include.cmake, adding component
|
# Perform component processing (inclusion of project_include.cmake, adding component
|
||||||
# subdirectories, creating library targets, linking libraries, etc.)
|
# subdirectories, creating library targets, linking libraries, etc.)
|
||||||
idf_build_get_property(idf_path IDF_PATH)
|
idf_build_get_property(idf_path IDF_PATH)
|
||||||
add_subdirectory(${idf_path} ${build_dir}/esp-idf)
|
add_subdirectory(${idf_path} ${build_dir}/esp-idf)
|
||||||
endfunction()
|
endmacro()
|
||||||
|
|
||||||
# idf_build_executable
|
# idf_build_executable
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user