[cmake-developers] Introducing: message(DEBUG)

Rolf Eike Beer eike at sf-mail.de
Sat Mar 3 05:25:27 EST 2012


I have a small patch to CMake that looks like this:

diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index e1dbf34..ad24368 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -52,6 +52,18 @@ bool cmMessageCommand
     status = true;
     ++i;
     }
+  else if (*i == "DEBUG")
+    {
+    if (!this->Makefile->GetCMakeInstance()->GetDebugOutput())
+      {
+      if (!this->Makefile->IsOn("CMAKE_DEBUG_MESSAGES"))
+        {
+        return true;
+        }
+      }
+    status = true;
+    ++i;
+    }
 
   for(;i != args.end(); ++i)
     {

The idea behind this is like that: you can write message(DEBUG ...) everywhere 
in your CMake code and it will just print out nothing. Once you run cmake --
debug-output these messages will behave like message(STATUS), i.e. give you 
their contents and call trace. If at the point of the message(DEBUG) call a 
variable CMAKE_DEBUG_MESSAGES is set the message will behave like a normal 
message(STATUS), too. This variable is a completely normal CMake variable, 
i.e. it follows the normal scoping rules. My idea is to go into 
Modules/Find*.cmake and e.g. replace if(Boost_DEBUG) message(...) endif() just 
by "CMAKE_DEBUG_MESSAGES |= Boost_DEBUG" message(DEBUG ...).

Opinions?

Eike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20120303/c776d7f0/attachment.sig>


More information about the cmake-developers mailing list