Added OSG_CPP_EXCEPTIONS_AVAILABLE cmake option to enable optional build of plugins and examples that required C++ exceptions
This commit is contained in:
parent
f417706b06
commit
79f766efab
@ -301,6 +301,8 @@ OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex
|
||||
OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE})
|
||||
OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." ${OSG_GL1_AVAILABLE})
|
||||
|
||||
OPTION(OSG_CPP_EXCEPTIONS_AVAILABLE "Set to OFF to disable compile of OSG components that use C++ exceptions." ON)
|
||||
|
||||
################################################################################
|
||||
# Set Config file
|
||||
|
||||
|
@ -58,7 +58,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osglogicop)
|
||||
ADD_SUBDIRECTORY(osglogo)
|
||||
ADD_SUBDIRECTORY(osgmanipulator)
|
||||
ADD_SUBDIRECTORY(osgmemorytest)
|
||||
ADD_SUBDIRECTORY(osgmovie)
|
||||
ADD_SUBDIRECTORY(osgmultiplerendertargets)
|
||||
ADD_SUBDIRECTORY(osgmultitexture)
|
||||
@ -107,7 +106,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgtexturerectangle)
|
||||
ADD_SUBDIRECTORY(osgtexturecompression)
|
||||
ADD_SUBDIRECTORY(osgthirdpersonview)
|
||||
ADD_SUBDIRECTORY(osgunittests)
|
||||
ADD_SUBDIRECTORY(osgvertexprogram)
|
||||
ADD_SUBDIRECTORY(osgvertexattributes)
|
||||
ADD_SUBDIRECTORY(osgvolume)
|
||||
@ -137,16 +135,21 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgwidgettable)
|
||||
ADD_SUBDIRECTORY(osgwidgetwindow)
|
||||
|
||||
IF(NOT OSG_GLES1_AVAILABLE AND NOT OSG_GLES2_AVAILABLE AND NOT OSG_GL3_AVAILABLE)
|
||||
ADD_SUBDIRECTORY(osgscreencapture)
|
||||
ADD_SUBDIRECTORY(osgmotionblur)
|
||||
ADD_SUBDIRECTORY(osgteapot)
|
||||
ENDIF()
|
||||
IF(OSG_CPP_EXCEPTIONS_AVAILABLE)
|
||||
ADD_SUBDIRECTORY(osgunittests)
|
||||
ADD_SUBDIRECTORY(osgmemorytest)
|
||||
ENDIF()
|
||||
|
||||
IF(OSG_GLU_AVAILABLE)
|
||||
ADD_SUBDIRECTORY(osgphotoalbum)
|
||||
ADD_SUBDIRECTORY(osgtessellate)
|
||||
ENDIF()
|
||||
IF(NOT OSG_GLES1_AVAILABLE AND NOT OSG_GLES2_AVAILABLE AND NOT OSG_GL3_AVAILABLE)
|
||||
ADD_SUBDIRECTORY(osgscreencapture)
|
||||
ADD_SUBDIRECTORY(osgmotionblur)
|
||||
ADD_SUBDIRECTORY(osgteapot)
|
||||
ENDIF()
|
||||
|
||||
IF(OSG_GLU_AVAILABLE)
|
||||
ADD_SUBDIRECTORY(osgphotoalbum)
|
||||
ADD_SUBDIRECTORY(osgtessellate)
|
||||
ENDIF()
|
||||
|
||||
ADD_SUBDIRECTORY(osgpdf)
|
||||
|
||||
|
@ -164,7 +164,6 @@ ENDIF()
|
||||
|
||||
ADD_SUBDIRECTORY(bvh)
|
||||
ADD_SUBDIRECTORY(x)
|
||||
ADD_SUBDIRECTORY(ply)
|
||||
ADD_SUBDIRECTORY(dxf)
|
||||
ADD_SUBDIRECTORY(OpenFlight)
|
||||
# ADD_SUBDIRECTORY(flt)
|
||||
@ -186,13 +185,17 @@ ADD_SUBDIRECTORY(md2)
|
||||
ADD_SUBDIRECTORY(osgtgz)
|
||||
ADD_SUBDIRECTORY(tgz)
|
||||
|
||||
ADD_SUBDIRECTORY(txp)
|
||||
ADD_SUBDIRECTORY(shp)
|
||||
ADD_SUBDIRECTORY(txf)
|
||||
|
||||
ADD_SUBDIRECTORY(bsp)
|
||||
ADD_SUBDIRECTORY(mdl)
|
||||
|
||||
IF(OSG_CPP_EXCEPTIONS_AVAILABLE)
|
||||
ADD_SUBDIRECTORY(ply)
|
||||
ADD_SUBDIRECTORY(txp)
|
||||
ENDIF()
|
||||
|
||||
IF(XINE_FOUND)
|
||||
ADD_SUBDIRECTORY(xine)
|
||||
ENDIF()
|
||||
|
@ -1,8 +1,13 @@
|
||||
INCLUDE_DIRECTORIES( ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
|
||||
|
||||
IF(OSG_CPP_EXCEPTIONS_AVAILABLE)
|
||||
ADD_DEFINITIONS(-DOSG_CPP_EXCEPTIONS_AVAILABLE)
|
||||
ENDIF()
|
||||
|
||||
SET(TARGET_SRC ReaderWriterPNG.cpp )
|
||||
SET(TARGET_LIBRARIES_VARS PNG_LIBRARY ZLIB_LIBRARY )
|
||||
|
||||
|
||||
#### end var setup ###
|
||||
SETUP_PLUGIN(png)
|
||||
|
||||
|
@ -51,7 +51,11 @@ private:
|
||||
|
||||
void user_error_fn(png_structp png_ptr, png_const_charp error_msg)
|
||||
{
|
||||
#ifdef OSG_CPP_EXCEPTIONS_AVAILABLE
|
||||
throw PNGError(error_msg);
|
||||
#else
|
||||
osg::notify(osg::WARN) << "PNG lib warning : " << error_msg << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg)
|
||||
@ -166,9 +170,10 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
|
||||
// Set custom error handlers
|
||||
png_set_error_fn(png, png_get_error_ptr(png), user_error_fn, user_warning_fn);
|
||||
|
||||
#ifdef OSG_CPP_EXCEPTIONS_AVAILABLE
|
||||
try
|
||||
#endif
|
||||
{
|
||||
|
||||
info = png_create_info_struct(png);
|
||||
endinfo = png_create_info_struct(png);
|
||||
|
||||
@ -300,13 +305,16 @@ class ReaderWriterPNG : public osgDB::ReaderWriter
|
||||
osg::Image::USE_NEW_DELETE);
|
||||
|
||||
return pOsgImage;
|
||||
|
||||
}
|
||||
#ifdef OSG_CPP_EXCEPTIONS_AVAILABLE
|
||||
catch (PNGError& err)
|
||||
{
|
||||
osg::notify(osg::WARN) << err << std::endl;
|
||||
png_destroy_read_struct(&png, &info, &endinfo);
|
||||
return ReadResult::ERROR_IN_READING_FILE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int getCompressionLevel(const osgDB::ReaderWriter::Options *options) const
|
||||
|
Loading…
Reference in New Issue
Block a user