Am Samstag, 3. März 2012, 12:45:12 schrieb Eric Noulard:
> 2012/3/3 Rolf Eike Beer <e...@sf-mail.de>:
> > 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?
>
> I like it, I thought about similar feature when writing CPackRPM.cmake
> which uses the "CPACK_RPM_PACKAGE_DEBUG" for the same purpose.
>
> However I thing that debug output should usually be prefixed by the context
> emitting the  message in order to be able to tell debug output apart.
>
> Thus I would rather have
>
> message(DEBUG ...) automatically prefix with the name of the current list
> file (for example) or may be adding a variable
> CMAKE_DEBUG_MESSAGES_PREFIX with local scope which may
> be set by the module/list file write before calling
> message(DEBUG ...)
>
> currently in CPackRPM I do:
>
> MESSAGE("CPackRPM:Debug: rpmbuild version is
> <${RPMBUILD_EXECUTABLE_VERSION}>")
>
> I would like to be able to write:
>
> set(CMAKE_DEBUG_MESSAGES_PREFIX "CPackRPM:Debug: ")
> ...
> MESSAGE(DEBUG "rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>")
> ....
> That way I would have typed the prefix once for the whole CPackRPM.cmake
> file.

This is a nice idea.

> Note that if one begins to use "message(DEBUG" instead of  "if(Boost_DEBUG)"
> you won't be able to have selective debug output anymore, i.e.
> activating DEBUG output
> would enable debug output for all module/list files which may not be
> as convenient
> as set(Boost_DEBUG 1)
>
> or may be that what you meant by
> CMAKE_DEBUG_MESSAGES |= Boost_DEBUG ?
> message(DEBUG ...)

My patch to FindBoost.cmake begins with:

diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 9c03b3d..e30381a 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -257,6 +257,10 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)

+set(CMAKE_DEBUG_MESSAGES_OLD ${CMAKE_DEBUG_MESSAGES})
+if (CMAKE_DEBUG_MESSAGES OR Boost_DEBUG)
+  set(CMAKE_DEBUG_MESSAGES TRUE)
+endif()

So the idea is that you get Boost debug messages
-if you call cmake --debug-output
-if you set Boost_DEBUG before including the Boost Module (for backward
compatibility)
-if you set CMAKE_DEBUG_MESSAGES before including the Boost Module

Eike

Attachment: signature.asc
Description: This is a digitally signed message part.

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to