From accaf1f7398fccf116cd5abf2b06a8ec2f1ace9c Mon Sep 17 00:00:00 2001 From: Diederick Niehorster Date: Sun, 27 Jan 2013 12:38:28 +0000 Subject: [PATCH] can now configure build such that runtime warnings and/or errors occuring in lib are not printed to stderr (thanks Nigel Steward) git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1501 7f0cb862-5218-0410-a997-914c9d46530a --- CMakeLists.txt | 6 ++++++ config.h.in | 4 ++++ src/fg_main.c | 6 ++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37d61aa..26b03a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,12 @@ set(VERSION_PATCH 0) OPTION(BUILD_SHARED_LIBS "Build FreeGLUT shared library." ON) OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON) +# option for whether warnings and errors should be printed +OPTION(FREEGLUT_ERRORS "Lib prints errors to stderr" ON) +#MARK_AS_ADVANCED(FREEGLUT_ERRORS) +OPTION(FREEGLUT_WARNINGS "Lib prints warnings to stderr" ON) +#MARK_AS_ADVANCED(FREEGLUT_WARNINGS) + # option to also copy .pdb files to install directory when executing # INSTALL target IF(MSVC) diff --git a/config.h.in b/config.h.in index 823ff07..11af946 100644 --- a/config.h.in +++ b/config.h.in @@ -23,3 +23,7 @@ #define VERSION_MAJOR @VERSION_MAJOR@ #define VERSION_MINOR @VERSION_MINOR@ #define VERSION_PATCH @VERSION_PATCH@ + +/* warning and errors printed? */ +#define FREEGLUT_WARNINGS @FREEGLUT_WARNINGS@ +#define FREEGLUT_ERRORS @FREEGLUT_ERRORS@ diff --git a/src/fg_main.c b/src/fg_main.c index c3bccdc..0a096f4 100644 --- a/src/fg_main.c +++ b/src/fg_main.c @@ -261,7 +261,7 @@ void fgError( const char *fmt, ... ) va_end( ap ); } else { - +#if FREEGLUT_ERRORS va_start( ap, fmt ); fprintf( stderr, "freeglut "); @@ -271,6 +271,7 @@ void fgError( const char *fmt, ... ) fprintf( stderr, "\n" ); va_end( ap ); +#endif if ( fgState.Initialised ) fgDeinitialize (); @@ -293,7 +294,7 @@ void fgWarning( const char *fmt, ... ) va_end( ap ); } else { - +#if FREEGLUT_WARNINGS va_start( ap, fmt ); fprintf( stderr, "freeglut "); @@ -303,6 +304,7 @@ void fgWarning( const char *fmt, ... ) fprintf( stderr, "\n" ); va_end( ap ); +#endif } } -- 1.7.10.4