feat(cmakev2): add idf_build_get_compile_options and use in compat and component

Add idf_build_get_compile_options() to aggregate COMPILE_OPTIONS,
C_COMPILE_OPTIONS, CXX_COMPILE_OPTIONS, and ASM_COMPILE_OPTIONS build
properties with generator expressions. Replace internal
__get_compile_options(OUTPUT ...) usage in idf_component_register and
idf_component_include with the new public function.
This commit is contained in:
Sudeep Mohanty
2026-03-20 08:13:26 +01:00
committed by Frantisek Hrbata
parent c4fcce84cc
commit d782a2c4eb
3 changed files with 8 additions and 15 deletions
+1 -1
View File
@@ -427,7 +427,7 @@ function(idf_component_register)
idf_build_get_property(compile_definitions COMPILE_DEFINITIONS GENERATOR_EXPRESSION) idf_build_get_property(compile_definitions COMPILE_DEFINITIONS GENERATOR_EXPRESSION)
add_compile_definitions("${compile_definitions}") add_compile_definitions("${compile_definitions}")
__get_compile_options(OUTPUT compile_options) idf_build_get_compile_options(compile_options)
add_compile_options("${compile_options}") add_compile_options("${compile_options}")
idf_build_get_property(common_component_interfaces __COMMON_COMPONENT_INTERFACES) idf_build_get_property(common_component_interfaces __COMMON_COMPONENT_INTERFACES)
+1 -1
View File
@@ -1055,6 +1055,6 @@ function(idf_component_include name)
idf_build_get_property(compile_definitions COMPILE_DEFINITIONS GENERATOR_EXPRESSION) idf_build_get_property(compile_definitions COMPILE_DEFINITIONS GENERATOR_EXPRESSION)
target_compile_definitions("${component_real_target}" PRIVATE "${compile_definitions}") target_compile_definitions("${component_real_target}" PRIVATE "${compile_definitions}")
__get_compile_options(OUTPUT compile_options) idf_build_get_compile_options(compile_options)
target_compile_options("${component_real_target}" BEFORE PRIVATE "${compile_options}") target_compile_options("${component_real_target}" BEFORE PRIVATE "${compile_options}")
endfunction() endfunction()
+6 -13
View File
@@ -609,26 +609,19 @@ function(__split)
endfunction() endfunction()
#[[ #[[
__get_compile_options(OUTPUT <variable>) idf_build_get_compile_options(<variable>)
*OUTPUT[out]* *variable*
List of generator expressions for C, CXX, and ASM compile options Variable name in which the list of generator expressions for C, CXX,
and ASM compile options will be stored.
Gather the compilation options from COMPILE_OPTIONS, C_COMPILE_OPTIONS, Gather the compilation options from COMPILE_OPTIONS, C_COMPILE_OPTIONS,
CXX_COMPILE_OPTIONS, and ASM_COMPILE_OPTIONS build properties into a single CXX_COMPILE_OPTIONS, and ASM_COMPILE_OPTIONS build properties into a single
list using generator expressions. This list can then be used with the list using generator expressions. This list can then be used with the
target_compile_options call. target_compile_options call.
#]] #]]
function(__get_compile_options) function(idf_build_get_compile_options output)
set(options)
set(one_value OUTPUT)
set(multi_value)
cmake_parse_arguments(ARG "${options}" "${one_value}" "${multi_value}" ${ARGN})
if(NOT DEFINED ARG_OUTPUT)
idf_die("OUTPUT option is required")
endif()
idf_build_get_property(compile_options COMPILE_OPTIONS GENERATOR_EXPRESSION) idf_build_get_property(compile_options COMPILE_OPTIONS GENERATOR_EXPRESSION)
idf_build_get_property(c_compile_options C_COMPILE_OPTIONS GENERATOR_EXPRESSION) idf_build_get_property(c_compile_options C_COMPILE_OPTIONS GENERATOR_EXPRESSION)
idf_build_get_property(cxx_compile_options CXX_COMPILE_OPTIONS GENERATOR_EXPRESSION) idf_build_get_property(cxx_compile_options CXX_COMPILE_OPTIONS GENERATOR_EXPRESSION)
@@ -643,7 +636,7 @@ function(__get_compile_options)
foreach(option IN LISTS asm_compile_options) foreach(option IN LISTS asm_compile_options)
list(APPEND compile_options $<$<COMPILE_LANGUAGE:ASM>:${option}>) list(APPEND compile_options $<$<COMPILE_LANGUAGE:ASM>:${option}>)
endforeach() endforeach()
set(${ARG_OUTPUT} "${compile_options}" PARENT_SCOPE) set(${output} "${compile_options}" PARENT_SCOPE)
endfunction() endfunction()
#[[ #[[