spark: 增加 SparkCMakeDebugConfig.cmake 提供内部信息调试能力

This commit is contained in:
zinface 2023-04-06 15:59:27 +08:00
parent 474aa840ec
commit aba6da24dd
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
# SparkCMakeDebugConfig.cmake
option(SPARK_CMAKE_DEBUG "CMake内部信息调试能力" ON)
set(SPARK_CMAKE_DEBUG_FILE "${CMAKE_BINARY_DIR}/spark_debug.txt")
set(SPARK_CMAKE_CONTENT_FILE "${CMAKE_BINARY_DIR}/spark_debug_content.txt")
#
file(WRITE ${SPARK_CMAKE_CONTENT_FILE} "")
# spark_cmake_debug <message> ...
#
function(spark_cmake_debug)
list(JOIN ARGN "\n" _content)
file(APPEND ${SPARK_CMAKE_CONTENT_FILE} "${_content}\n")
endfunction()
# spark_generator_cmake_debug <target>
# <target>
function(spark_generator_cmake_debug _target)
add_custom_target(${_target}
COMMAND ${CMAKE_COMMAND} -E cat
${SPARK_CMAKE_DEBUG_FILE}
)
file(GENERATE
OUTPUT
${SPARK_CMAKE_DEBUG_FILE}
INPUT
${SPARK_CMAKE_CONTENT_FILE})
endfunction(spark_generator_cmake_debug _target)
#
# 1. 使 spark_cmake_debug( <content> [...])
#
#
#
# 2. 使 spark_generator_cmake_debug( <target> )
# <target>
# 使 function
#