mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
fix(cmake): quote variable references in conditional expressions
Closes https://github.com/espressif/esp-idf/issues/18445
This commit is contained in:
@@ -77,22 +77,22 @@ function(__parse_and_store_version_arg)
|
|||||||
cmake_parse_arguments(PROJECT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(PROJECT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
# If the VERSION keyword exists but no version string is provided then raise a warning
|
# If the VERSION keyword exists but no version string is provided then raise a warning
|
||||||
if((NOT PROJECT_VERSION
|
if(("${PROJECT_VERSION}" STREQUAL ""
|
||||||
OR PROJECT_VERSION STREQUAL "NOTFOUND")
|
OR "${PROJECT_VERSION}" STREQUAL "NOTFOUND")
|
||||||
AND NOT PROJECT_VERSION STREQUAL "0")
|
AND NOT "${PROJECT_VERSION}" STREQUAL "0")
|
||||||
message(STATUS "VERSION keyword not followed by a value or was followed by a value that expanded to nothing.")
|
message(STATUS "VERSION keyword not followed by a value or was followed by a value that expanded to nothing.")
|
||||||
# Default the version to 1 in this case
|
# Default the version to 1 in this case
|
||||||
set(project_ver 1)
|
set(project_ver 1)
|
||||||
else()
|
else()
|
||||||
# Check if version is valid. cmake allows the version to be in the format <major>[.<minor>[.<patch>[.<tweak>]]]]
|
# Check if version is valid. cmake allows the version to be in the format <major>[.<minor>[.<patch>[.<tweak>]]]]
|
||||||
string(REGEX MATCH "^([0-9]+(\\.[0-9]+(\\.[0-9]+(\\.[0-9]+)?)?)?)?$" version_valid ${PROJECT_VERSION})
|
string(REGEX MATCH "^([0-9]+(\\.[0-9]+(\\.[0-9]+(\\.[0-9]+)?)?)?)?$" version_valid "${PROJECT_VERSION}")
|
||||||
if(NOT version_valid AND NOT PROJECT_VERSION STREQUAL "0")
|
if(NOT version_valid AND NOT "${PROJECT_VERSION}" STREQUAL "0")
|
||||||
message(SEND_ERROR "Version \"${PROJECT_VERSION}\" format invalid.")
|
message(SEND_ERROR "Version \"${PROJECT_VERSION}\" format invalid.")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Split the version string into major, minor, patch, and tweak components
|
# Split the version string into major, minor, patch, and tweak components
|
||||||
string(REPLACE "." ";" version_components ${PROJECT_VERSION})
|
string(REPLACE "." ";" version_components "${PROJECT_VERSION}")
|
||||||
list(GET version_components 0 PROJECT_VERSION_MAJOR)
|
list(GET version_components 0 PROJECT_VERSION_MAJOR)
|
||||||
list(LENGTH version_components version_length)
|
list(LENGTH version_components version_length)
|
||||||
if(version_length GREATER 1)
|
if(version_length GREATER 1)
|
||||||
@@ -733,7 +733,7 @@ macro(project project_name)
|
|||||||
# Check if version information was passed to project() via the VERSION argument
|
# Check if version information was passed to project() via the VERSION argument
|
||||||
set(version_keyword_present FALSE)
|
set(version_keyword_present FALSE)
|
||||||
foreach(arg ${ARGN})
|
foreach(arg ${ARGN})
|
||||||
if(${arg} STREQUAL "VERSION")
|
if("${arg}" STREQUAL "VERSION")
|
||||||
set(version_keyword_present TRUE)
|
set(version_keyword_present TRUE)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ macro(__target_init config_file)
|
|||||||
|
|
||||||
# Check if selected target is consistent with CMake cache
|
# Check if selected target is consistent with CMake cache
|
||||||
if(DEFINED CACHE{IDF_TARGET})
|
if(DEFINED CACHE{IDF_TARGET})
|
||||||
if(NOT $CACHE{IDF_TARGET} STREQUAL ${env_idf_target})
|
if(NOT $CACHE{IDF_TARGET} STREQUAL "${env_idf_target}")
|
||||||
message(FATAL_ERROR " IDF_TARGET '$CACHE{IDF_TARGET}' in CMake"
|
message(FATAL_ERROR " IDF_TARGET '$CACHE{IDF_TARGET}' in CMake"
|
||||||
" cache does not match currently selected IDF_TARGET '${env_idf_target}'."
|
" cache does not match currently selected IDF_TARGET '${env_idf_target}'."
|
||||||
" To change the target, clear the build directory and sdkconfig file,"
|
" To change the target, clear the build directory and sdkconfig file,"
|
||||||
@@ -105,7 +105,7 @@ macro(__target_init config_file)
|
|||||||
# Check if selected target is consistent with sdkconfig
|
# Check if selected target is consistent with sdkconfig
|
||||||
__target_from_config("${config_file}" sdkconfig_target where)
|
__target_from_config("${config_file}" sdkconfig_target where)
|
||||||
if(sdkconfig_target)
|
if(sdkconfig_target)
|
||||||
if(NOT ${sdkconfig_target} STREQUAL ${env_idf_target})
|
if(NOT "${sdkconfig_target}" STREQUAL "${env_idf_target}")
|
||||||
message(FATAL_ERROR " Target '${sdkconfig_target}' in sdkconfig '${where}'"
|
message(FATAL_ERROR " Target '${sdkconfig_target}' in sdkconfig '${where}'"
|
||||||
" does not match currently selected IDF_TARGET '${IDF_TARGET}'."
|
" does not match currently selected IDF_TARGET '${IDF_TARGET}'."
|
||||||
" To change the target, clear the build directory and sdkconfig file,"
|
" To change the target, clear the build directory and sdkconfig file,"
|
||||||
@@ -143,7 +143,7 @@ macro(__target_set_toolchain)
|
|||||||
" the build directory and sdkconfig file, and build the project again.")
|
" the build directory and sdkconfig file, and build the project again.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${env_idf_toolchain} STREQUAL "clang")
|
if("${env_idf_toolchain}" STREQUAL "clang")
|
||||||
# TODO IDF-14338: remove the line below since it will be set in toolchain.cmake
|
# TODO IDF-14338: remove the line below since it will be set in toolchain.cmake
|
||||||
set(IDF_TOOLCHAIN ${env_idf_toolchain} CACHE STRING "IDF Build Toolchain Type")
|
set(IDF_TOOLCHAIN ${env_idf_toolchain} CACHE STRING "IDF Build Toolchain Type")
|
||||||
set(toolchain_filename "toolchain-clang-${IDF_TARGET}.cmake")
|
set(toolchain_filename "toolchain-clang-${IDF_TARGET}.cmake")
|
||||||
|
|||||||
Reference in New Issue
Block a user