mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(toolchain): more remove_duplicated_flags function to separate file
Currently, the toolchain CMake files use the remove_duplicated_flags function from utilities.cmake. The cmakev2 implementation also includes this function for backward compatibility. Move the remove_duplicated_flags function to a separate file, deduplicate_flags.cmake, so it can be shared between cmakev1 and cmakev2. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
# Remove duplicates from a string containing compilation flags
|
||||||
|
function(remove_duplicated_flags FLAGS UNIQFLAGS)
|
||||||
|
set(FLAGS_LIST "${FLAGS}")
|
||||||
|
# Convert the given flags, as a string, into a CMake list type
|
||||||
|
separate_arguments(FLAGS_LIST)
|
||||||
|
# Remove all the duplicated flags
|
||||||
|
list(REMOVE_DUPLICATES FLAGS_LIST)
|
||||||
|
# Convert the list back to a string
|
||||||
|
string(REPLACE ";" " " FLAGS_LIST "${FLAGS_LIST}")
|
||||||
|
# Return that string to the caller
|
||||||
|
set(${UNIQFLAGS} "${FLAGS_LIST}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_NAME Generic)
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/deduplicate_flags.cmake)
|
||||||
|
|
||||||
# set_default
|
# set_default
|
||||||
#
|
#
|
||||||
# Define a variable to a default value if otherwise unset.
|
# Define a variable to a default value if otherwise unset.
|
||||||
@@ -457,17 +459,3 @@ function(add_deprecated_target_alias old_target new_target)
|
|||||||
)
|
)
|
||||||
add_dependencies(${old_target} ${new_target})
|
add_dependencies(${old_target} ${new_target})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
# Remove duplicates from a string containing compilation flags
|
|
||||||
function(remove_duplicated_flags FLAGS UNIQFLAGS)
|
|
||||||
set(FLAGS_LIST "${FLAGS}")
|
|
||||||
# Convert the given flags, as a string, into a CMake list type
|
|
||||||
separate_arguments(FLAGS_LIST)
|
|
||||||
# Remove all the duplicated flags
|
|
||||||
list(REMOVE_DUPLICATES FLAGS_LIST)
|
|
||||||
# Convert the list back to a string
|
|
||||||
string(REPLACE ";" " " FLAGS_LIST "${FLAGS_LIST}")
|
|
||||||
# Return that string to the caller
|
|
||||||
set(${UNIQFLAGS} "${FLAGS_LIST}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
# To maintain backward compatibility for those who might expect
|
||||||
|
# remove_duplicated_flags to be available when utilities.cmake is included,
|
||||||
|
# we ensure its presence. The remove_duplicated_flags function is primarily
|
||||||
|
# used by toolchain CMake files.
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/deduplicate_flags.cmake)
|
||||||
|
|
||||||
# Note: CMake does not support nested lists. The functions idf_die, idf_warn,
|
# Note: CMake does not support nested lists. The functions idf_die, idf_warn,
|
||||||
# idf_msg, and idf_dbg use ARGV# values because this is the only way to prevent
|
# idf_msg, and idf_dbg use ARGV# values because this is the only way to prevent
|
||||||
# arguments from being altered by CMake. ARGV and ARGN contain a flattened list
|
# arguments from being altered by CMake. ARGV and ARGN contain a flattened list
|
||||||
@@ -606,31 +612,6 @@ function(__get_compile_options)
|
|||||||
set(${ARG_OUTPUT} "${compile_options}" PARENT_SCOPE)
|
set(${ARG_OUTPUT} "${compile_options}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
#[[
|
|
||||||
remove_duplicated_flags(<flags> <uniq_flags>)
|
|
||||||
|
|
||||||
*flags[in]*
|
|
||||||
|
|
||||||
Input string with compilation flags.
|
|
||||||
|
|
||||||
*uniq_flags[out]*
|
|
||||||
|
|
||||||
Output string with unified compilation flags.
|
|
||||||
|
|
||||||
Remove duplicate entries from a string of compilation flags.
|
|
||||||
#]]
|
|
||||||
function(remove_duplicated_flags FLAGS UNIQFLAGS)
|
|
||||||
set(FLAGS_LIST "${FLAGS}")
|
|
||||||
# Convert the given flags, as a string, into a CMake list type
|
|
||||||
separate_arguments(FLAGS_LIST)
|
|
||||||
# Remove all the duplicated flags
|
|
||||||
list(REMOVE_DUPLICATES FLAGS_LIST)
|
|
||||||
# Convert the list back to a string
|
|
||||||
string(REPLACE ";" " " FLAGS_LIST "${FLAGS_LIST}")
|
|
||||||
# Return that string to the caller
|
|
||||||
set(${UNIQFLAGS} "${FLAGS_LIST}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
#[[
|
#[[
|
||||||
spaces2list(<variable>)
|
spaces2list(<variable>)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user