diff --git a/EXR/ReadEXR.cpp b/EXR/ReadEXR.cpp index 85aeb69..103eaf5 100644 --- a/EXR/ReadEXR.cpp +++ b/EXR/ReadEXR.cpp @@ -38,15 +38,33 @@ #include "ofxsMacros.h" +// Check OpenEXR version to determine header locations +#include +#define COMBINED_OPENEXR_VERSION ((10000*OPENEXR_VERSION_MAJOR) + \ + (100*OPENEXR_VERSION_MINOR) + \ + OPENEXR_VERSION_PATCH) + GCC_DIAG_OFF(deprecated) -#include -#include -#include -#include -#include -#include -#include -#include +#if COMBINED_OPENEXR_VERSION >= 20599 /* 2.5.99: pre-3.0 */ +# include +# include +# include +# include +# include +# include +# include +# include +#else + // OpenEXR 2.x, use the old locations +# include +# include +# include +# include +# include +# include +# include +# include +#endif GCC_DIAG_ON(deprecated) #ifdef OFX_IO_MT_EXR diff --git a/EXR/WriteEXR.cpp b/EXR/WriteEXR.cpp index 6711b87..b03c69f 100644 --- a/EXR/WriteEXR.cpp +++ b/EXR/WriteEXR.cpp @@ -27,16 +27,33 @@ #include "ofxsFileOpen.h" #include "ofxsMacros.h" +#include +#define COMBINED_OPENEXR_VERSION ((10000*OPENEXR_VERSION_MAJOR) + \ + (100*OPENEXR_VERSION_MINOR) + \ + OPENEXR_VERSION_PATCH) + GCC_DIAG_OFF(deprecated) -#include -#include -#include -#include -#include -#include -#include -#include -#include +#if COMBINED_OPENEXR_VERSION >= 20599 /* 2.5.99: pre-3.0 */ +# include +# include +# include +# include +# include +# include +# include +# include +# include +#else + // OpenEXR 2.x, use the old locations +# include +# include +# include +# include +# include +# include +# include +# include +# include GCC_DIAG_ON(deprecated) #include "GenericOCIO.h" @@ -267,6 +284,10 @@ WriteEXRPlugin::encode(const string& filename, } else { Imf_::Array2D halfwriterow(pixelDataNComps, bounds.x2 - bounds.x1); +#if COMBINED_OPENEXR_VERSION >= 20599 /* 2.5.99: pre-3.0 */ + using Imath::half; +#endif + for (int chan = 0; chan < pixelDataNComps; ++chan) { fbuf.insert(chanNames[chan], Imf_::Slice(Imf_::HALF, diff --git a/Makefile.master b/Makefile.master index 8b27df8..ddd0420 100644 --- a/Makefile.master +++ b/Makefile.master @@ -24,9 +24,12 @@ endif # OpenEXR # OpenImageIO includes OpenEXR as #include , to we also add the # include dir itself to avoid confusion with a system-installed OpenEXR. -# OpenEXR 2 has IlmBase, OpenEXR 3 has Imath, so we ask for both, but it will always cause harmless errors. -OPENEXR_CXXFLAGS = -I`pkg-config --variable=prefix OpenEXR`/include `pkg-config --cflags IlmBase 2>/dev/null` `pkg-config --cflags Imath 2>/dev/null` `pkg-config --cflags OpenEXR` -OPENEXR_LINKFLAGS =`pkg-config --libs IlmBase 2>/dev/null` `pkg-config --libs Imath 2>/dev/null` `pkg-config --libs OpenEXR` +# OpenEXR 2 has IlmBase, OpenEXR 3 has Imath, so we ask for both. +# Try Imath first (OpenEXR 3.x), then fallback to IlmBase (OpenEXR 2.x) +IMATH_CXXFLAGS := $(shell pkg-config --cflags Imath 2>/dev/null || pkg-config --cflags IlmBase 2>/dev/null) +IMATH_LINKFLAGS := $(shell pkg-config --libs Imath 2>/dev/null || pkg-config --libs IlmBase 2>/dev/null) +OPENEXR_CXXFLAGS = -I`pkg-config --variable=prefix OpenEXR`/include $(IMATH_CXXFLAGS) `pkg-config --cflags OpenEXR` +OPENEXR_LINKFLAGS = $(IMATH_LINKFLAGS) `pkg-config --libs OpenEXR` # Uncomment the following line to enable multithreaded EXR reading (untested, and probably does not make sense) #OPENEXR_CXXFLAGS += -DOFX_IO_MT_EXR @@ -37,7 +40,7 @@ FFMPEG_LINKFLAGS = `pkg-config --libs libavformat libavcodec libswscale libavuti FFMPEG_CXXFLAGS += -DOFX_IO_MT_FFMPEG # OpenImageIO -OIIO_CXXFLAGS = $(OCIO_CXXFLAGS) `pkg-config --cflags OpenImageIO` $(OPENEXR_CFLAGS) -DOFX_IO_USING_LIBRAW `pkg-config --cflags libraw_r libwebp libtiff-4 libopenjp2 libpng` +OIIO_CXXFLAGS = $(OCIO_CXXFLAGS) `pkg-config --cflags OpenImageIO` $(OPENEXR_CXXFLAGS) -DOFX_IO_USING_LIBRAW `pkg-config --cflags libraw_r libwebp libtiff-4 libopenjp2 libpng` OIIO_LINKFLAGS = $(OCIO_LINKFLAGS) `pkg-config --libs OpenImageIO` $(OPENEXR_LINKFLAGS) `pkg-config --libs libraw_r libwebp libtiff-4 libopenjp2 libpng` ifeq ($(OS),Linux) # libraw_r may be in a separate directory for licence reasons (eg in the Natron SDK)