cmake: On configure error suggest looking at CMake*.log files
When CMake reports failure to configure a project, especially when the toolchain does not initialize properly, the true reason may be clear from reading the CMakeFiles/CMake(Output|Error).log files. Advise users to look at these files if they exist when configuration fails. Add RunCMake.Configure test to check that the log files are mentioned when configuration fails.
This commit is contained in:
parent
448a677148
commit
18e1bfbb3c
@ -892,12 +892,28 @@ void cmGlobalGenerator::Configure()
|
||||
|
||||
if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE)
|
||||
{
|
||||
const char* msg = "Configuring done";
|
||||
cmOStringStream msg;
|
||||
if(cmSystemTools::GetErrorOccuredFlag())
|
||||
{
|
||||
msg = "Configuring incomplete, errors occurred!";
|
||||
msg << "Configuring incomplete, errors occurred!";
|
||||
const char* logs[] = {"CMakeOutput.log", "CMakeError.log", 0};
|
||||
for(const char** log = logs; *log; ++log)
|
||||
{
|
||||
std::string f = this->CMakeInstance->GetHomeOutputDirectory();
|
||||
f += this->CMakeInstance->GetCMakeFilesDirectory();
|
||||
f += "/";
|
||||
f += *log;
|
||||
if(cmSystemTools::FileExists(f.c_str()))
|
||||
{
|
||||
msg << "\nSee also \"" << f << "\".";
|
||||
}
|
||||
}
|
||||
}
|
||||
this->CMakeInstance->UpdateProgress(msg, -1);
|
||||
else
|
||||
{
|
||||
msg << "Configuring done";
|
||||
}
|
||||
this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ add_RunCMake_test(CTest)
|
||||
if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles")
|
||||
add_RunCMake_test(CompilerChange)
|
||||
endif()
|
||||
add_RunCMake_test(Configure)
|
||||
add_RunCMake_test(ExternalData)
|
||||
add_RunCMake_test(FPHSA)
|
||||
add_RunCMake_test(GeneratorExpression)
|
||||
|
3
Tests/RunCMake/Configure/CMakeLists.txt
Normal file
3
Tests/RunCMake/Configure/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
1
Tests/RunCMake/Configure/ErrorLogs-result.txt
Normal file
1
Tests/RunCMake/Configure/ErrorLogs-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
4
Tests/RunCMake/Configure/ErrorLogs-stderr.txt
Normal file
4
Tests/RunCMake/Configure/ErrorLogs-stderr.txt
Normal file
@ -0,0 +1,4 @@
|
||||
CMake Error at ErrorLogs.cmake:3 \(message\):
|
||||
Some error!
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
3
Tests/RunCMake/Configure/ErrorLogs-stdout.txt
Normal file
3
Tests/RunCMake/Configure/ErrorLogs-stdout.txt
Normal file
@ -0,0 +1,3 @@
|
||||
-- Configuring incomplete, errors occurred!
|
||||
See also ".*/Tests/RunCMake/Configure/ErrorLogs-build/CMakeFiles/CMakeOutput\.log"\.
|
||||
See also ".*/Tests/RunCMake/Configure/ErrorLogs-build/CMakeFiles/CMakeError\.log"\.
|
3
Tests/RunCMake/Configure/ErrorLogs.cmake
Normal file
3
Tests/RunCMake/Configure/ErrorLogs.cmake
Normal file
@ -0,0 +1,3 @@
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Some detailed error information!\n")
|
||||
message(SEND_ERROR "Some error!")
|
3
Tests/RunCMake/Configure/RunCMakeTest.cmake
Normal file
3
Tests/RunCMake/Configure/RunCMakeTest.cmake
Normal file
@ -0,0 +1,3 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(ErrorLogs)
|
Loading…
x
Reference in New Issue
Block a user