mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(cmakev2/build): add __init_build() stub
Most of the global settings are configured in idf.cmake, but certain elements can only be initialized after the project() function is called and the toolchain is set up. For example, this includes the compilation options, which may depend on identified compiler or the project name and version set in the project() call. The __init_build function is called at the beginning of the idf_build_library() function, meaning it should be executed after the project() call. It ensures that initialization occurs only once by setting the __BUILD_INITIALIZED build property. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -89,6 +89,24 @@ function(__dump_build_properties)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
__init_build()
|
||||
|
||||
Initialize settings that need to be configured after the project() function
|
||||
is called. This primarily involves setting compilation options, define
|
||||
settings, and configuring linker options.
|
||||
#]]
|
||||
function(__init_build)
|
||||
idf_build_get_property(build_initialized __BUILD_INITIALIZED)
|
||||
if(build_initialized)
|
||||
# Ensure this function is executed only once throughout the entire
|
||||
# project.
|
||||
return()
|
||||
endif()
|
||||
|
||||
idf_build_set_property(__BUILD_INITIALIZED YES)
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
__get_library_interface_or_die(LIBRARY <library>
|
||||
OUTPUT <variable>)
|
||||
@@ -243,6 +261,10 @@ function(idf_build_library)
|
||||
set(ARG_COMPONENTS "${component_names}")
|
||||
endif()
|
||||
|
||||
# Initialize settings that must be configured after the project() function
|
||||
# is called.
|
||||
__init_build()
|
||||
|
||||
add_library("${ARG_INTERFACE}" INTERFACE)
|
||||
idf_build_set_property(LIBRARY_INTERFACES "${ARG_INTERFACE}" APPEND)
|
||||
idf_library_set_property("${ARG_INTERFACE}" LIBRARY_COMPONENTS "${ARG_COMPONENTS}")
|
||||
|
||||
Reference in New Issue
Block a user