Modules: Record system inspection steps in the configure log

Replace old-style `file(APPEND .../CMake{Output,Error}.log)` logging
with calls to `message(CONFIGURE_LOG)` to record the steps in the
`CMakeConfigureLog.yaml` configure log instead.

Issue: #23200
This commit is contained in:
Brad King
2023-01-16 14:41:19 -05:00
parent 0f688386ea
commit f6ed2585e5
17 changed files with 126 additions and 57 deletions

View File

@@ -520,10 +520,10 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
set(_SET_CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT
"set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT \"${CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT}\")")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Parsed CUDA nvcc implicit link information from above output:\n${_nvcc_log}\n${log}\n\n")
message(CONFIGURE_LOG
"Parsed CUDA nvcc implicit link information:\n${_nvcc_log}\n${log}\n\n")
else()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
message(CONFIGURE_LOG
"Failed to parse CUDA nvcc implicit link information:\n${_nvcc_log}\n\n")
message(FATAL_ERROR "Failed to extract nvcc implicit link line.")
endif()
@@ -576,10 +576,10 @@ if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
list(APPEND CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "${line}")
endforeach()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Parsed CUDA nvcc include information from above output:\n${_nvcc_log}\n${log}\n\n")
message(CONFIGURE_LOG
"Parsed CUDA nvcc include information:\n${_nvcc_log}\n${log}\n\n")
else()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
message(CONFIGURE_LOG
"Failed to detect CUDA nvcc include information:\n${_nvcc_log}\n\n")
endif()

View File

@@ -124,8 +124,8 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
set (implicit_incdirs "")
cmake_parse_implicit_include_info("${OUTPUT}" "${lang}"
implicit_incdirs log rv)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Parsed ${lang} implicit include dir info from above output: rv=${rv}\n${log}\n\n")
message(CONFIGURE_LOG
"Parsed ${lang} implicit include dir info: rv=${rv}\n${log}\n\n")
if("${rv}" STREQUAL "done")
# Entries that we have been told to explicitly pass as standard include
# directories will not be implicitly added by the compiler.
@@ -149,8 +149,8 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
"${CMAKE_${lang}_IMPLICIT_OBJECT_REGEX}"
COMPUTE_IMPLICIT_OBJECTS implicit_objs
LANGUAGE ${lang})
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Parsed ${lang} implicit link information from above output:\n${log}\n\n")
message(CONFIGURE_LOG
"Parsed ${lang} implicit link information:\n${log}\n\n")
endif()
# for VS IDE Intel Fortran we have to figure out the
# implicit link path for the fortran run time using

View File

@@ -2,6 +2,8 @@
# file Copyright.txt or https://cmake.org/licensing for details.
macro(__determine_compiler_id_test testflags_var userflags_var)
set(_CMAKE_${lang}_COMPILER_ID_LOG "")
separate_arguments(testflags UNIX_COMMAND "${${testflags_var}}")
CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${testflags}" "${${userflags_var}}" "${src}")
CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}")
@@ -11,6 +13,9 @@ macro(__determine_compiler_id_test testflags_var userflags_var)
CMAKE_DETERMINE_COMPILER_ID_CHECK("${lang}" "${CMAKE_${lang}_COMPILER_ID_DIR}/${file}" "${src}")
endforeach()
endif()
message(CONFIGURE_LOG "${_CMAKE_${lang}_COMPILER_ID_LOG}")
unset(_CMAKE_${lang}_COMPILER_ID_LOG)
endmacro()
# Function to compile a source file to identify the compiler. This is
@@ -114,7 +119,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
RESULT_VARIABLE result
TIMEOUT 10
)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
message(CONFIGURE_LOG
"Running the ${lang} compiler: \"${CMAKE_${lang}_COMPILER}\" -version\n"
"${output}\n"
)
@@ -138,7 +143,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
RESULT_VARIABLE result
TIMEOUT 10
)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
message(CONFIGURE_LOG
"Running the ${lang} compiler: \"${CMAKE_${lang}_COMPILER}\" -version\n"
"${output}\n"
)
@@ -158,7 +163,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
RESULT_VARIABLE result
TIMEOUT 10
)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
message(CONFIGURE_LOG
"Running the ${lang} compiler: \"${CMAKE_${lang}_COMPILER}\" --version\n"
"${output}\n"
)
@@ -732,7 +737,7 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
")
# Log the output unless we recognize it as a known-bad case.
if(NOT CMAKE_${lang}_COMPILER_ID_OUTPUT MATCHES "warning #5117: Bad # preprocessor line")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${MSG}")
string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG "${MSG}")
endif()
string(APPEND _CMAKE_DETERMINE_COMPILER_ID_BUILD_MSG "${MSG}")
@@ -752,7 +757,7 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
set(COMPILER_${lang}_PRODUCED_OUTPUT)
else()
# Compilation succeeded.
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG
"Compiling the ${lang} compiler identification source file \"${src}\" succeeded.
${COMPILER_DESCRIPTION}
The output was:
@@ -781,7 +786,7 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
foreach(file ${files})
if(NOT IS_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}/${file})
list(APPEND COMPILER_${lang}_PRODUCED_FILES ${file})
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG
"Compilation of the ${lang} compiler identification source \""
"${src}\" produced \"${file}\"\n\n")
endif()
@@ -789,7 +794,7 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
if(NOT COMPILER_${lang}_PRODUCED_FILES)
# No executable was found.
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG
"Compilation of the ${lang} compiler identification source \""
"${src}\" did not produce an executable in \""
"${CMAKE_${lang}_COMPILER_ID_DIR}\".\n\n")
@@ -801,6 +806,7 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
# Return the files produced by the compilation.
set(COMPILER_${lang}_PRODUCED_FILES "${COMPILER_${lang}_PRODUCED_FILES}" PARENT_SCOPE)
set(COMPILER_${lang}_PRODUCED_OUTPUT "${COMPILER_${lang}_PRODUCED_OUTPUT}" PARENT_SCOPE)
set(_CMAKE_${lang}_COMPILER_ID_LOG "${_CMAKE_${lang}_COMPILER_ID_LOG}" PARENT_SCOPE)
endfunction()
@@ -994,15 +1000,16 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
# Check the compiler identification string.
if(CMAKE_${lang}_COMPILER_ID)
# The compiler identification was found.
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"The ${lang} compiler identification is ${CMAKE_${lang}_COMPILER_ID}, found in \""
"${file}\"\n\n")
string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG
"The ${lang} compiler identification is ${CMAKE_${lang}_COMPILER_ID}, found in:\n"
" ${file}\n\n")
else()
# The compiler identification could not be found.
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"The ${lang} compiler identification could not be found in \""
"${file}\"\n\n")
string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG
"The ${lang} compiler identification could not be found in:\n"
" ${file}\n\n")
endif()
set(_CMAKE_${lang}_COMPILER_ID_LOG "${_CMAKE_${lang}_COMPILER_ID_LOG}" PARENT_SCOPE)
endif()
# try to figure out the executable format: ELF, COFF, Mach-O
@@ -1089,7 +1096,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang userflags)
)
if("${output}" MATCHES "${regex}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
message(CONFIGURE_LOG
"Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
"matched \"${regex}\":\n${output}")
set(CMAKE_${lang}_COMPILER_ID "${vendor}" PARENT_SCOPE)
@@ -1098,11 +1105,11 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang userflags)
break()
else()
if("${result}" MATCHES "timeout")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
message(CONFIGURE_LOG
"Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
"terminated after 10 s due to timeout.")
else()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
message(CONFIGURE_LOG
"Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
"did not match \"${regex}\":\n${output}")
endif()

View File

@@ -187,11 +187,11 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN)
if(NOT CMAKE_COMPILER_RETURN)
if(CMAKE_COMPILER_OUTPUT MATCHES "THIS_IS_GNU")
set(CMAKE_Fortran_COMPILER_ID "GNU")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
message(CONFIGURE_LOG
"Determining if the Fortran compiler is GNU succeeded with "
"the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
else()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
message(CONFIGURE_LOG
"Determining if the Fortran compiler is GNU failed with "
"the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
endif()

View File

@@ -196,13 +196,14 @@ endif()
if(CMAKE_BINARY_DIR)
# write entry to the log file
if(PRESET_CMAKE_SYSTEM_NAME)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"The target system is: ${CMAKE_SYSTEM_NAME} - ${CMAKE_SYSTEM_VERSION} - ${CMAKE_SYSTEM_PROCESSOR}\n")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"The host system is: ${CMAKE_HOST_SYSTEM_NAME} - ${CMAKE_HOST_SYSTEM_VERSION} - ${CMAKE_HOST_SYSTEM_PROCESSOR}\n")
message(CONFIGURE_LOG
"The target system is: ${CMAKE_SYSTEM_NAME} - ${CMAKE_SYSTEM_VERSION} - ${CMAKE_SYSTEM_PROCESSOR}\n"
"The host system is: ${CMAKE_HOST_SYSTEM_NAME} - ${CMAKE_HOST_SYSTEM_VERSION} - ${CMAKE_HOST_SYSTEM_PROCESSOR}\n"
)
else()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"The system is: ${CMAKE_SYSTEM_NAME} - ${CMAKE_SYSTEM_VERSION} - ${CMAKE_SYSTEM_PROCESSOR}\n")
message(CONFIGURE_LOG
"The system is: ${CMAKE_SYSTEM_NAME} - ${CMAKE_SYSTEM_VERSION} - ${CMAKE_SYSTEM_PROCESSOR}\n"
)
endif()
# if a toolchain file is used, it needs to be included in the configured file,

View File

@@ -60,7 +60,7 @@ if(CMAKE_CUDA_ABI_COMPILED)
set(_CUDA_ARCHS_STATUS "")
endif()
string(REPLACE "\n" "\n " _CUDA_ARCHS_OUTPUT " ${_CUDA_ARCHS_OUTPUT}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
message(CONFIGURE_LOG
"Detecting the CUDA native architecture(s) failed with "
"the following output:\n${_CUDA_ARCHS_OUTPUT}\n\n")
endif()

View File

@@ -90,14 +90,14 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
)
include(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/result.cmake OPTIONAL)
if(CMAKE_${lang}_COMPILER AND "${_cl_result}" STREQUAL "0")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
message(CONFIGURE_LOG
"${_desc} passed with the following output:\n"
"${_cl_output}\n")
set(_CHECK_COMPILER_STATUS CHECK_PASS)
else()
set(CMAKE_${lang}_COMPILER NOTFOUND)
set(_CHECK_COMPILER_STATUS CHECK_FAIL)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
message(CONFIGURE_LOG
"${_desc} failed with the following output:\n"
"${_cl_output}\n")
endif()

View File

@@ -14,7 +14,7 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS AND NOT CMAKE_Fortran_COMPILER_FORCED)
string(REGEX REPLACE "/[^/]*$" "" _nag_dir "${_nag_obj}")
string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" _nag_regex "${_nag_dir}")
set(CMAKE_Fortran_IMPLICIT_OBJECT_REGEX "^${_nag_regex}/")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
message(CONFIGURE_LOG
"Detecting NAG Fortran directory with -dryrun found\n"
" object: ${_nag_obj}\n"
" directory: ${_nag_dir}\n"
@@ -22,7 +22,7 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS AND NOT CMAKE_Fortran_COMPILER_FORCED)
"from output:\n${_dryrun}\n\n")
message(CHECK_PASS "${_nag_dir}")
else()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
message(CONFIGURE_LOG
"Detecting NAG Fortran directory with -dryrun failed:\n${_dryrun}\n\n")
message(CHECK_FAIL "failed")
endif()

View File

@@ -238,9 +238,6 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR)
LANGUAGE ${LANG}
)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Parsed ${LANG} OpenMP implicit link information from above output:\n${OpenMP_${LANG}_LOG_VAR}\n\n")
# For LCC we should additionally alanyze -print-search-dirs output
# to check for additional implicit_dirs.
# Note: This won't work if CMP0129 policy is set to OLD!
@@ -253,11 +250,14 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR)
if("${output_lines}" MATCHES ".*\nlibraries:[ \t]+(.*:)\n.*")
string(REPLACE ":" ";" implicit_dirs_addon "${CMAKE_MATCH_1}")
list(PREPEND OpenMP_${LANG}_IMPLICIT_LINK_DIRS ${implicit_dirs_addon})
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
string(APPEND OpenMP_${LANG}_LOG_VAR
" Extended OpenMP library search paths: [${implicit_dirs}]\n")
endif()
endif()
message(CONFIGURE_LOG
"Parsed ${LANG} OpenMP implicit link information from above output:\n${OpenMP_${LANG}_LOG_VAR}\n\n")
unset(_OPENMP_LIB_NAMES)
foreach(_OPENMP_IMPLICIT_LIB IN LISTS OpenMP_${LANG}_IMPLICIT_LIBRARIES)
get_filename_component(_OPENMP_IMPLICIT_LIB_DIR "${_OPENMP_IMPLICIT_LIB}" DIRECTORY)

View File

@@ -51,7 +51,7 @@ function(CMAKE_TRY_COMPILER_OR_LINKER_FLAG lang flag result)
if (NOT lang MATCHES "^(C|CXX|Fortran|ASM)$")
# other possible languages are not supported
# log message to keep trace of this problem...
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
message(CONFIGURE_LOG
"Function 'CMAKE_CHECK_COMPILER_FLAG' called with unsupported language: ${lang}\n")
set(${result} FALSE CACHE INTERNAL ${comment})
return()
@@ -144,7 +144,7 @@ function(CMAKE_TRY_COMPILER_OR_LINKER_FLAG lang flag result)
endforeach()
endif()
if (DEFINED ${result})
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
message(CONFIGURE_LOG
"Determining if the ${flag} option "
"is supported for ${lang} language failed with the following output:\n"
"${COMPILER_FLAG_OUTPUT}\n")

View File

@@ -70,7 +70,7 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio")
endif()
endif()
if(VCXPROJ_INSPECT_RESULT)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
message(CONFIGURE_LOG
"Determining the sysroot for the Android NDK failed.
The output was:
${VCXPROJ_INSPECT_RESULT}
@@ -78,7 +78,7 @@ ${VCXPROJ_INSPECT_OUTPUT}
")
else()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
message(CONFIGURE_LOG
"Determining the sysroot for the Android NDK succeeded.
The output was:
${VCXPROJ_INSPECT_RESULT}

View File

@@ -1,4 +1,4 @@
CMake Error at ErrorLogs.cmake:3 \(message\):
CMake Error at ErrorLogs.cmake:[0-9]+ \(message\):
Some error!
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
CMakeLists.txt:[0-9]+ \(include\)

View File

@@ -1,3 +1,5 @@
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Some detailed output information!\n")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Some detailed error information!\n")
message(SEND_ERROR "Some error!")

View File

@@ -1,6 +1,13 @@
^
---
events:
events:(
-
kind: "message-v1"
backtrace:(
- "[^"]+")+
message: \|(
+ [^
]*)*)+
-
kind: "try_compile-v1"
backtrace:
@@ -17,7 +24,14 @@ events:
variable: "CMAKE_C_ABI_COMPILED"
cached: true
stdout: \|.*
exitCode: 0
exitCode: 0(
-
kind: "message-v1"
backtrace:(
- "[^"]+")+
message: \|(
+ [^
]*)*)*
-
kind: "try_compile-v1"
backtrace:

View File

@@ -1,6 +1,13 @@
^
---
events:
events:(
-
kind: "message-v1"
backtrace:(
- "[^"]+")+
message: \|(
+ [^
]*)*)+
-
kind: "try_compile-v1"
backtrace:
@@ -17,7 +24,14 @@ events:
variable: "CMAKE_C_ABI_COMPILED"
cached: true
stdout: \|.*
exitCode: 0
exitCode: 0(
-
kind: "message-v1"
backtrace:(
- "[^"]+")+
message: \|(
+ [^
]*)*)+
-
kind: "try_compile-v1"
backtrace:
@@ -34,5 +48,12 @@ events:
variable: "CMAKE_CXX_ABI_COMPILED"
cached: true
stdout: \|.*
exitCode: 0
exitCode: 0(
-
kind: "message-v1"
backtrace:(
- "[^"]+")+
message: \|(
+ [^
]*)*)*
\.\.\.$

View File

@@ -1 +1,11 @@
^$
^
---
events:(
-
kind: "message-v1"
backtrace:(
- "[^"]+")+
message: \|(
+ [^
]*)*)+
\.\.\.$

View File

@@ -1,6 +1,13 @@
^
---
events:
events:(
-
kind: "message-v1"
backtrace:(
- "[^"]+")+
message: \|(
+ [^
]*)*)+
-
kind: "try_compile-v1"
backtrace:
@@ -16,7 +23,14 @@ events:
variable: "CMAKE_C_ABI_COMPILED"
cached: true
stdout: \|.*
exitCode: 0
exitCode: 0(
-
kind: "message-v1"
backtrace:(
- "[^"]+")+
message: \|(
+ [^
]*)*)*
-
kind: "try_run-v1"
backtrace: