Tests: Avoid using CMake{Output,Error}.log files

These log files will soon go away, so avoid using them in tests.
This commit is contained in:
Brad King
2023-01-18 14:33:39 -05:00
parent 20bbd5f3d3
commit 95976514f6
6 changed files with 35 additions and 17 deletions

View File

@@ -33,6 +33,7 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
RESULT_VARIABLE result
)
include(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran/result.cmake OPTIONAL)
# FIXME: Replace with message(CONFIGURE_LOG) when CMake version is high enough.
if(CMAKE_Fortran_COMPILER AND "${result}" STREQUAL "0")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"${_desc} passed with the following output:\n"

View File

@@ -42,6 +42,7 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
include(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift/result.cmake
OPTIONAL)
# FIXME: Replace with message(CONFIGURE_LOG) when CMake version is high enough.
if(CMAKE_Swift_COMPILER AND "${result}" STREQUAL "0")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"${_desc} passed with the following output:\n"

View File

@@ -56,8 +56,6 @@ add_custom_target(checksayhello ALL
)
add_dependencies(checksayhello sayhello)
set(err_log ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log)
file(REMOVE "${err_log}")
include(CheckFortranSourceCompiles)
unset(HAVE_PRINT CACHE)
CHECK_Fortran_SOURCE_COMPILES([[
@@ -66,10 +64,24 @@ CHECK_Fortran_SOURCE_COMPILES([[
END
]] HAVE_PRINT)
if(NOT HAVE_PRINT)
if(EXISTS "${err_log}")
file(READ "${err_log}" err)
set(configure_log "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeConfigureLog.yaml")
if(EXISTS "${configure_log}")
file(READ "${configure_log}" log_content)
else()
set(log_content "")
endif()
if(log_content MATCHES [[( -
kind: "try_compile-v1"(
+ [^
]+)+
checks:
- "Performing Test HAVE_PRINT"(
+ [^
]+)+)]])
set(err "${CMAKE_MATCH_1}")
else()
set(err "")
endif()
string(REPLACE "\n" "\n " err " ${err}")
message(SEND_ERROR "CHECK_Fortran_SOURCE_COMPILES for HAVE_PRINT failed:\n"
"${err}")
endif()

View File

@@ -1,2 +1 @@
-- Configuring incomplete, errors occurred!
See also ".*/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-build/CMakeFiles/CMakeOutput\.log".

View File

@@ -1,10 +1,6 @@
cmake_policy(SET CMP0067 NEW)
enable_language(CXX)
# Isolate the one try_compile below in the error log.
set(CMakeError_log "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log")
file(REMOVE "${CMakeError_log}")
# Add our own -std= flag to the try_compile check.
set(CMAKE_REQUIRED_FLAGS -std=c++11)
@@ -24,8 +20,21 @@ int main()
}
" SRC_COMPILED)
if(NOT SRC_COMPILED)
if(EXISTS "${CMakeError_log}")
file(READ "${CMakeError_log}" err_log)
message("Check failed to compile:")
set(configure_log "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeConfigureLog.yaml")
if(EXISTS "${configure_log}")
file(READ "${configure_log}" log_content)
else()
set(log_content "")
endif()
if(log_content MATCHES [[( -
kind: "try_compile-v1"(
+ [^
]+)+
checks:
- "Performing Test SRC_COMPILED"(
+ [^
]+)+)]])
message("${configure_log} contains:\n${CMAKE_MATCH_1}")
endif()
message("${err_log}")
endif()

View File

@@ -63,13 +63,9 @@ int main(int, char* [])
DumpInformation_BINARY_DIR "/OtherProperties.txt",
DumpInformation_BINARY_DIR "/../../Source/cmConfigure.h",
DumpInformation_BINARY_DIR "/../../CMakeCache.txt",
DumpInformation_BINARY_DIR "/../../CMakeFiles/CMakeOutput.log",
DumpInformation_BINARY_DIR "/../../CMakeFiles/CMakeError.log",
DumpInformation_BINARY_DIR "/../../Bootstrap.cmk/cmake_bootstrap.log",
DumpInformation_BINARY_DIR "/../../Source/cmsys/Configure.hxx",
DumpInformation_BINARY_DIR "/../../Source/cmsys/Configure.h",
DumpInformation_BINARY_DIR "/CMakeFiles/CMakeOutput.log",
DumpInformation_BINARY_DIR "/CMakeFiles/CMakeError.log",
0
};