From 41dda781eee11675490f8e97b009e432321e72fe Mon Sep 17 00:00:00 2001 From: Raymond de Vries Date: Tue, 14 Nov 2017 10:38:18 +0000 Subject: [PATCH] attached fixes for configuring and building the osgPlugin exr with Visual Studio and using out-of-the-box builds of ilmbase and openexr, i.e. without manual/extra config for using these 2 libs with the OSG. Previously, the assumption was made that ilmbase and openexr were installed in a common directory and hence the header files and libs were both found in that common directory. That is not consistent with other libs and this submission makes it consistent and therefore the OSG configures out of the box. I made this work for ilmbase-2.1.0.tar.gz / openexr-2.1.0.tar.gz and ilmbase-2.2.0.tar.gz / openexr-2.2.0.tar.gz --- CMakeLists.txt | 1 + CMakeModules/FindOpenEXR.cmake | 13 +++---- CMakeModules/Findilmbase.cmake | 63 +++++++++++++++++++++++++++++++ src/osgPlugins/exr/CMakeLists.txt | 3 +- 4 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 CMakeModules/Findilmbase.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 79b25311d..396a959f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -742,6 +742,7 @@ IF(ANDROID) ELSE() # Common to all platforms except android: FIND_PACKAGE(Freetype) + FIND_PACKAGE(ilmbase) FIND_PACKAGE(Inventor) FIND_PACKAGE(Jasper) FIND_PACKAGE(OpenEXR) diff --git a/CMakeModules/FindOpenEXR.cmake b/CMakeModules/FindOpenEXR.cmake index 743df98fb..233be972b 100644 --- a/CMakeModules/FindOpenEXR.cmake +++ b/CMakeModules/FindOpenEXR.cmake @@ -28,7 +28,7 @@ FIND_PATH(OPENEXR_INCLUDE_DIR OpenEXR/ImfIO.h # example: OPENEXR_FIND_VAR(OPENEXR_IlmImf_LIBRARY IlmImf) MACRO(OPENEXR_FIND_VAR varname libname) FIND_LIBRARY( ${varname} - NAMES ${libname} + NAMES ${libname} ${libname}-2_1 ${libname}-2_2 PATHS $ENV{OPENEXR_DIR}/lib $ENV{OPENEXR_DIR} @@ -52,13 +52,10 @@ MACRO(OPENEXR_FIND libname) ENDMACRO(OPENEXR_FIND) OPENEXR_FIND(IlmImf) -OPENEXR_FIND(IlmThread) -OPENEXR_FIND(Iex) -OPENEXR_FIND(Half) SET(OPENEXR_FOUND "NO") -IF(OPENEXR_INCLUDE_DIR AND OPENEXR_IlmImf_LIBRARY AND OPENEXR_IlmThread_LIBRARY AND OPENEXR_Iex_LIBRARY AND OPENEXR_Half_LIBRARY) - SET(OPENEXR_LIBRARIES ${OPENEXR_IlmImf_LIBRARY} ${OPENEXR_IlmThread_LIBRARY} ${OPENEXR_Half_LIBRARY} ${OPENEXR_Iex_LIBRARY} ) - SET(OPENEXR_LIBRARIES_VARS OPENEXR_IlmImf_LIBRARY OPENEXR_IlmThread_LIBRARY OPENEXR_Half_LIBRARY OPENEXR_Iex_LIBRARY ) +IF(OPENEXR_INCLUDE_DIR AND OPENEXR_IlmImf_LIBRARY) + SET(OPENEXR_LIBRARIES ${OPENEXR_IlmImf_LIBRARY} ) + SET(OPENEXR_LIBRARIES_VARS OPENEXR_IlmImf_LIBRARY ) SET(OPENEXR_FOUND "YES") -ENDIF(OPENEXR_INCLUDE_DIR AND OPENEXR_IlmImf_LIBRARY AND OPENEXR_IlmThread_LIBRARY AND OPENEXR_Iex_LIBRARY AND OPENEXR_Half_LIBRARY) +ENDIF(OPENEXR_INCLUDE_DIR AND OPENEXR_IlmImf_LIBRARY) diff --git a/CMakeModules/Findilmbase.cmake b/CMakeModules/Findilmbase.cmake new file mode 100644 index 000000000..4b076c7c9 --- /dev/null +++ b/CMakeModules/Findilmbase.cmake @@ -0,0 +1,63 @@ +# Locate ILMBASE +# This module defines +# ILMBASE_LIBRARY +# ILMBASE_FOUND, if false, do not try to link to ILMBASE +# ILMBASE_INCLUDE_DIR, where to find the headers +# +# $ILMBASE_DIR is an environment variable that would +# correspond to the ./configure --prefix=$ILMBASE_DIR +# +# Created by Robert Osfield. + + +FIND_PATH(ILMBASE_INCLUDE_DIR OpenEXR/ImathVec.h + $ENV{ILMBASE_DIR}/include + $ENV{ILMBASE_DIR} + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include + /usr/include + /sw/include # Fink + /opt/local/include # DarwinPorts + /opt/csw/include # Blastwave + /opt/include + /usr/freeware/include +) + +# Macro to find ilmbase libraries +# example: ILMBASE_FIND_VAR(OPENEXR_IlmThread_LIBRARY IlmThread) +MACRO(ILMBASE_FIND_VAR varname libname) + FIND_LIBRARY( ${varname} + NAMES ${libname} ${libname}-2_1 ${libname}-2_2 + PATHS + $ENV{ILMBASE_DIR}/lib + $ENV{ILMBASE_DIR} + ~/Library/Frameworks + /Library/Frameworks + /usr/local/lib + /usr/lib + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib64 + ) +ENDMACRO(ILMBASE_FIND_VAR) + +# Macro to find exr libraries (and debug versions) +# example: ILMBASE_FIND(OPENEXR_IlmThread_LIBRARY IlmThread) +MACRO(ILMBASE_FIND libname) + ILMBASE_FIND_VAR(ILMBASE_${libname}_LIBRARY ${libname}) + ILMBASE_FIND_VAR(ILMBASE_${libname}_LIBRARY_DEBUG ${libname}d) +ENDMACRO(ILMBASE_FIND) + +ILMBASE_FIND(IlmThread) +ILMBASE_FIND(Iex) +ILMBASE_FIND(Half) + +SET(ILMBASE_FOUND "NO") +IF(ILMBASE_INCLUDE_DIR AND ILMBASE_IlmThread_LIBRARY AND ILMBASE_Iex_LIBRARY AND ILMBASE_Half_LIBRARY) + SET(ILMBASE_LIBRARIES ${ILMBASE_IlmThread_LIBRARY} ${ILMBASE_Half_LIBRARY} ${ILMBASE_Iex_LIBRARY} ) + SET(ILMBASE_LIBRARIES_VARS ILMBASE_IlmThread_LIBRARY ILMBASE_Half_LIBRARY ILMBASE_Iex_LIBRARY ) + SET(ILMBASE_FOUND "YES") +ENDIF(ILMBASE_INCLUDE_DIR AND ILMBASE_IlmThread_LIBRARY AND ILMBASE_Iex_LIBRARY AND ILMBASE_Half_LIBRARY) diff --git a/src/osgPlugins/exr/CMakeLists.txt b/src/osgPlugins/exr/CMakeLists.txt index 56ef8e0e4..e2ed9bb65 100644 --- a/src/osgPlugins/exr/CMakeLists.txt +++ b/src/osgPlugins/exr/CMakeLists.txt @@ -1,8 +1,9 @@ +INCLUDE_DIRECTORIES( ${ILMBASE_INCLUDE_DIR}/OpenEXR ) INCLUDE_DIRECTORIES( ${OPENEXR_INCLUDE_DIR}/OpenEXR ) SET(TARGET_SRC ReaderWriterEXR.cpp ) -SET(TARGET_LIBRARIES_VARS ${OPENEXR_LIBRARIES_VARS} ZLIB_LIBRARIES) +SET(TARGET_LIBRARIES_VARS ${OPENEXR_LIBRARIES_VARS} ${ILMBASE_LIBRARIES_VARS} ZLIB_LIBRARIES) IF(CMAKE_COMPILER_IS_GNUCXX) # Remove -Wshadow flag as it barfs on ffmoeg headers