[cmake-developers] Capturing messages to log files (was: Wrapping functions in CMake)

Clifford Yapp cliffyapp at gmail.com
Sat Jul 18 15:45:49 EDT 2015


On Wed, Jul 15, 2015 at 9:10 AM, Brad King <brad.king at kitware.com> wrote:
> On 07/09/2015 01:53 PM, Clifford Yapp wrote:
>> Actually, thinking about that, what's really needed is not an
>> in-memory log but a way to specify log files, since an unexpected
>> crash or exit is not a situation under which such in-memory logs could
>> be reliably written to disk.  So it would instead need to be
>> CMAKE_STATUS_MESSAGE_LOG, CMAKE_ERROR_MESSAGES_LOG, etc. which would
>> hold paths to which messages would be copied before being written to
>> stdout/stderr.
>
> These could be defined as GLOBAL properties since there can only
> be one.  Internally we already have callback infrastructure to
> dispatch where these messages go.  Hooks could be added to check
> these properties too.  Or, the property setting logic could have
> special handling for these properties to install the needed
> callbacks internally.  This approach would avoid opening/closing
> the log files over and over.  We could just keep them open all
> the time and flush after each write.

Brad,

Am I correct that cmSystemTools::Message is the gateway through which
all of the console output from CMake exits?  If so, perhaps the
simplest thing to do is simply allow copying to a log file at that
point?  It would be nice to have files containing only errors, only
warnings, etc. but it's not immediately clear to me how to set
something like that up...

CY


More information about the cmake-developers mailing list