message: Add a DEPRECATION mode
By default, the message is not issued. If CMAKE_ERROR_DEPRECATED is on, the message is fatal. If CMAKE_WARN_DEPRECATED is on, the message is a warning.
This commit is contained in:
parent
40c84683aa
commit
509c142a3f
@ -52,6 +52,23 @@ bool cmMessageCommand
|
|||||||
status = true;
|
status = true;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
else if (*i == "DEPRECATION")
|
||||||
|
{
|
||||||
|
if (this->Makefile->IsOn("CMAKE_ERROR_DEPRECATED"))
|
||||||
|
{
|
||||||
|
fatal = true;
|
||||||
|
type = cmake::DEPRECATION_ERROR;
|
||||||
|
}
|
||||||
|
else if (this->Makefile->IsOn("CMAKE_WARN_DEPRECATED"))
|
||||||
|
{
|
||||||
|
type = cmake::DEPRECATION_WARNING;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
for(;i != args.end(); ++i)
|
for(;i != args.end(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -60,9 +60,8 @@ public:
|
|||||||
virtual const char* GetFullDocumentation() const
|
virtual const char* GetFullDocumentation() const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
" message([STATUS|WARNING|AUTHOR_WARNING|FATAL_ERROR|SEND_ERROR]\n"
|
" message([<mode>] \"message to display\" ...)\n"
|
||||||
" \"message to display\" ...)\n"
|
"The optional <mode> keyword determines the type of message:\n"
|
||||||
"The optional keyword determines the type of message:\n"
|
|
||||||
" (none) = Important information\n"
|
" (none) = Important information\n"
|
||||||
" STATUS = Incidental information\n"
|
" STATUS = Incidental information\n"
|
||||||
" WARNING = CMake Warning, continue processing\n"
|
" WARNING = CMake Warning, continue processing\n"
|
||||||
@ -70,6 +69,9 @@ public:
|
|||||||
" SEND_ERROR = CMake Error, continue processing,\n"
|
" SEND_ERROR = CMake Error, continue processing,\n"
|
||||||
" but skip generation\n"
|
" but skip generation\n"
|
||||||
" FATAL_ERROR = CMake Error, stop processing and generation\n"
|
" FATAL_ERROR = CMake Error, stop processing and generation\n"
|
||||||
|
" DEPRECATION = CMake Deprecation Error or Warning if variable\n"
|
||||||
|
" CMAKE_ERROR_DEPRECATED or CMAKE_WARN_DEPRECATED\n"
|
||||||
|
" is enabled, respectively, else no message.\n"
|
||||||
"The CMake command-line tool displays STATUS messages on stdout "
|
"The CMake command-line tool displays STATUS messages on stdout "
|
||||||
"and all other message types on stderr. "
|
"and all other message types on stderr. "
|
||||||
"The CMake GUI displays all messages in its log area. "
|
"The CMake GUI displays all messages in its log area. "
|
||||||
|
@ -3127,6 +3127,15 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
|
|||||||
{
|
{
|
||||||
msg << "CMake Debug Log";
|
msg << "CMake Debug Log";
|
||||||
}
|
}
|
||||||
|
else if(t == cmake::DEPRECATION_ERROR)
|
||||||
|
{
|
||||||
|
msg << "CMake Deprecation Error";
|
||||||
|
isError = true;
|
||||||
|
}
|
||||||
|
else if (t == cmake::DEPRECATION_WARNING)
|
||||||
|
{
|
||||||
|
msg << "CMake Deprecation Warning";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg << "CMake Warning";
|
msg << "CMake Warning";
|
||||||
|
@ -65,7 +65,9 @@ class cmake
|
|||||||
INTERNAL_ERROR,
|
INTERNAL_ERROR,
|
||||||
MESSAGE,
|
MESSAGE,
|
||||||
WARNING,
|
WARNING,
|
||||||
LOG
|
LOG,
|
||||||
|
DEPRECATION_ERROR,
|
||||||
|
DEPRECATION_WARNING
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ add_RunCMake_test(if)
|
|||||||
add_RunCMake_test(include)
|
add_RunCMake_test(include)
|
||||||
add_RunCMake_test(include_directories)
|
add_RunCMake_test(include_directories)
|
||||||
add_RunCMake_test(list)
|
add_RunCMake_test(list)
|
||||||
|
add_RunCMake_test(message)
|
||||||
add_RunCMake_test(try_compile)
|
add_RunCMake_test(try_compile)
|
||||||
add_RunCMake_test(variable_watch)
|
add_RunCMake_test(variable_watch)
|
||||||
add_RunCMake_test(CMP0004)
|
add_RunCMake_test(CMP0004)
|
||||||
|
3
Tests/RunCMake/message/CMakeLists.txt
Normal file
3
Tests/RunCMake/message/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.4)
|
||||||
|
project(${RunCMake_TEST} NONE)
|
||||||
|
include(${RunCMake_TEST}.cmake)
|
5
Tests/RunCMake/message/RunCMakeTest.cmake
Normal file
5
Tests/RunCMake/message/RunCMakeTest.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
include(RunCMake)
|
||||||
|
|
||||||
|
run_cmake(nomessage)
|
||||||
|
run_cmake(warnmessage)
|
||||||
|
run_cmake(errormessage)
|
1
Tests/RunCMake/message/errormessage-result.txt
Normal file
1
Tests/RunCMake/message/errormessage-result.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
4
Tests/RunCMake/message/errormessage-stderr.txt
Normal file
4
Tests/RunCMake/message/errormessage-stderr.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
CMake Deprecation Error at errormessage.cmake:4 \(message\):
|
||||||
|
This is an error
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
4
Tests/RunCMake/message/errormessage.cmake
Normal file
4
Tests/RunCMake/message/errormessage.cmake
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
set(CMAKE_ERROR_DEPRECATED ON)
|
||||||
|
|
||||||
|
message(DEPRECATION "This is an error")
|
1
Tests/RunCMake/message/nomessage-result.txt
Normal file
1
Tests/RunCMake/message/nomessage-result.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
0
|
1
Tests/RunCMake/message/nomessage-stderr.txt
Normal file
1
Tests/RunCMake/message/nomessage-stderr.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
^$
|
2
Tests/RunCMake/message/nomessage.cmake
Normal file
2
Tests/RunCMake/message/nomessage.cmake
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
message(DEPRECATION "This is not issued")
|
1
Tests/RunCMake/message/warnmessage-result.txt
Normal file
1
Tests/RunCMake/message/warnmessage-result.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
0
|
4
Tests/RunCMake/message/warnmessage-stderr.txt
Normal file
4
Tests/RunCMake/message/warnmessage-stderr.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
CMake Deprecation Warning at warnmessage.cmake:4 \(message\):
|
||||||
|
This is a warning
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
4
Tests/RunCMake/message/warnmessage.cmake
Normal file
4
Tests/RunCMake/message/warnmessage.cmake
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
set(CMAKE_WARN_DEPRECATED ON)
|
||||||
|
|
||||||
|
message(DEPRECATION "This is a warning")
|
Loading…
x
Reference in New Issue
Block a user