diff options
author | Brad King <brad.king@kitware.com> | 2023-01-16 19:41:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-01-18 22:59:10 (GMT) |
commit | f6ed2585e595305d4866e4128bf98e9236b6ecd2 (patch) | |
tree | e8d924affc5a2e563038719cc0e20b15ee958fd0 /Modules/CMakeDetermineCompilerId.cmake | |
parent | 0f688386eabafb1e70a172004df8be4d9dc1d037 (diff) | |
download | CMake-f6ed2585e595305d4866e4128bf98e9236b6ecd2.zip CMake-f6ed2585e595305d4866e4128bf98e9236b6ecd2.tar.gz CMake-f6ed2585e595305d4866e4128bf98e9236b6ecd2.tar.bz2 |
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
Diffstat (limited to 'Modules/CMakeDetermineCompilerId.cmake')
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 8eec8f5..ece9f39 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -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() |