From 410b90334afc5e22c7c05cc1558e725864a2bf5d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 24 Nov 2008 16:32:52 +0000 Subject: [PATCH] From Wojciech Lewandowski, "I have restored MSVC disabled warnings in osg/Export. Difference is they are now disabled only when OSG_DISABLE_MSVC_WARNINGS macro is defined. This macro is set through CMake options and autogenerated in osg/Config. Simon suggested that it would be cool if we had more control over selected warnings. I tried to learn how to make selection of individual warning numbers possible, but had to gave up as my cmake skills were not sufficient. The only way I saw this possible would be adding one define for each MSVC warning number. But many definitions seemed too be to much clutter for osg/Config file so I rejected thar idea. For this it would be cool if autogenerated Config entries could more powerful than simple #define/#undef flags. Maybe Cmake gurus know how to do it. I have not reverted added Compiler options. I assume that one may want to have warnings enabled for the application but may not want to see them while OSG libraries and examples compile. Modified files: osg/Export - now explicitly includes osg/Config to make sure OSG_DISABLE_MSVC_WARNINGS is read osg/Config.in - declares OSG_DISABLE_MSVC_WARNINGS flag to be added to autogenerated osg/Config CMakeLists.txt - declares OSG_DISABLE_MSVC_WARNINGS as option with default ON setting " --- CMakeLists.txt | 3 +++ include/osg/Export | 15 ++++++++++++++- src/osg/Config.in | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b49ead73..88cfa6518 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,6 +271,9 @@ MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGBOX) OPTION(OSG_USE_UTF8_FILENAME "Set to ON to use a UTF8 locale for filenames instead of the default locale." OFF) MARK_AS_ADVANCED(OSG_USE_UTF8_FILENAME) +OPTION(OSG_DISABLE_MSVC_WARNINGS "Set to OFF to not disable MSVC wartnings genertated by OSG headers." ON) +MARK_AS_ADVANCED(OSG_DISABLE_MSVC_WARNINGS) + OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<> T* operator() output conversion. " ON) ################################################################################ diff --git a/include/osg/Export b/include/osg/Export index af9af4485..422a7ad00 100644 --- a/include/osg/Export +++ b/include/osg/Export @@ -14,11 +14,24 @@ #ifndef OSG_EXPORT_ #define OSG_EXPORT_ 1 +#include // define USE_DEPRECATED_API is used to include in API which is being fazed out // if you can compile your apps with this turned off you are // well placed for compatibility with future versions. #define USE_DEPRECATED_API +// disable VisualStudio warnings +#if defined(_MSC_VER) && defined(OSG_DISABLE_MSVC_WARNINGS) + #pragma warning( disable : 4244 ) + #pragma warning( disable : 4251 ) + #pragma warning( disable : 4267 ) + #pragma warning( disable : 4275 ) + #pragma warning( disable : 4290 ) + #pragma warning( disable : 4786 ) + #pragma warning( disable : 4305 ) + #pragma warning( disable : 4996 ) +#endif + #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__) # if defined( OSG_LIBRARY_STATIC ) # define OSG_EXPORT @@ -29,7 +42,7 @@ # endif #else # define OSG_EXPORT -#endif +#endif // set up define for whether member templates are supported by VisualStudio compilers. #ifdef _MSC_VER diff --git a/src/osg/Config.in b/src/osg/Config.in index d8c13b134..88aa642fa 100644 --- a/src/osg/Config.in +++ b/src/osg/Config.in @@ -29,5 +29,7 @@ #cmakedefine OSG_USE_FLOAT_BOUNDINGBOX #cmakedefine OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION #cmakedefine OSG_USE_UTF8_FILENAME +#cmakedefine OSG_DISABLE_MSVC_WARNINGS + #endif