项目文件夹

文件
2026-07-13 12:47:05 +08:00

88 行
3.1 KiB
CMake

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
################################################################################
# Colored Status Printing and Utility Functions
# Common utility functions for enhanced CMake output and debugging
################################################################################
# Enhanced colored status printing function
function(print_status_colored type message)
if(type STREQUAL "ERROR")
message(FATAL_ERROR "❌ ${message}")
elseif(type STREQUAL "WARNING")
message(WARNING "⚠️ ${message}")
elseif(type STREQUAL "SUCCESS")
message(STATUS "✅ ${message}")
elseif(type STREQUAL "INFO")
message(STATUS "️ ${message}")
elseif(type STREQUAL "DEBUG")
message(STATUS "🔍 ${message}")
elseif(type STREQUAL "NOTICE")
message(NOTICE "📢 ${message}")
else()
message(STATUS "${message}")
endif()
endfunction()
# Print all CMake variables for debugging
macro(print_all_variables)
message(STATUS "print_all_variables------------------------------------------{")
get_cmake_property(_variableNames VARIABLES)
foreach(_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
message(STATUS "print_all_variables------------------------------------------}")
endmacro()
# Function to verify template processing worked
function(verify_template_processing GENERATED_FILE)
if(EXISTS "${GENERATED_FILE}")
file(READ "${GENERATED_FILE}" FILE_CONTENT)
# Check for unprocessed #cmakedefine
if(FILE_CONTENT MATCHES "#cmakedefine[ \t]+[A-Za-z_]+")
message(FATAL_ERROR "❌ Template processing FAILED: ${GENERATED_FILE} contains unprocessed #cmakedefine directives")
endif()
# Check for unprocessed @VAR@
if(FILE_CONTENT MATCHES "@[A-Za-z_]+@")
message(FATAL_ERROR "❌ Template processing FAILED: ${GENERATED_FILE} contains unprocessed @VAR@ tokens")
endif()
message(STATUS "✅ Template processing verified: ${GENERATED_FILE}")
return()
else()
message(FATAL_ERROR "❌ Generated file does not exist: ${GENERATED_FILE}")
endif()
endfunction()
# Function to safely remove files if they match exclusion criteria
function(removeFileIfExcluded)
cmake_parse_arguments(
PARSED_ARGS
""
"FILE_ITEM"
"LIST_ITEM"
${ARGN}
)
file(READ ${PARSED_ARGS_FILE_ITEM} FILE_CONTENTS)
string(FIND "${FILE_CONTENTS}" "NOT_EXCLUDED" NOT_EXCLUDED_IDX)
if(${NOT_EXCLUDED_IDX} GREATER_EQUAL 0)
set(local_list ${${PARSED_ARGS_LIST_ITEM}})
set(file_removed FALSE)
foreach(OP ${SD_OPS_LIST})
string(FIND "${FILE_CONTENTS}" "NOT_EXCLUDED(OP_${OP})" NOT_EXCLUDED_OP_IDX)
if(${NOT_EXCLUDED_OP_IDX} LESS 0)
list(REMOVE_ITEM local_list "${PARSED_ARGS_FILE_ITEM}")
set(file_removed TRUE)
break()
endif()
endforeach()
if(file_removed)
set(${PARSED_ARGS_LIST_ITEM} ${local_list} PARENT_SCOPE)
endif()
endif()
endfunction()