This patch is an updated version of the patch created in dracwyrm's
patchset for openvdb 4.0.2 which uses PkgConfig to ensure that the
correct IlmBase and OpenEXR dependencies are found.

In subsequent versions this functionality is taken over by
altering the directory the header files are searched for in
multilib-header-source patch by Bernd Waibel

diff -urN a/openvdb/CMakeLists.txt b/openvdb/CMakeLists.txt
--- a/openvdb/CMakeLists.txt	2018-08-28 12:20:33.000000000 +0100
+++ b/openvdb/CMakeLists.txt	2018-08-28 12:25:19.807755722 +0100
@@ -83,11 +83,12 @@
   ADD_DEFINITIONS ( -DBOOST_ALL_NO_LIB )
 ENDIF ()
 
+FIND_PACKAGE ( PkgConfig REQUIRED )
 FIND_PACKAGE ( Blosc REQUIRED )
 FIND_PACKAGE ( TBB REQUIRED )
 FIND_PACKAGE ( ZLIB REQUIRED )
-FIND_PACKAGE ( ILMBase REQUIRED )
-FIND_PACKAGE ( OpenEXR REQUIRED )
+PKG_CHECK_MODULES ( ILMBASE_LIBS REQUIRED IlmBase )
+PKG_CHECK_MODULES ( OPENEXR_LIBS REQUIRED OpenEXR )
 FIND_PACKAGE ( OpenGL REQUIRED )
 IF (OPENVDB_BUILD_DOCS)
   FIND_PACKAGE ( Doxygen REQUIRED )
@@ -111,8 +112,8 @@
   INCLUDE_DIRECTORIES ( SYSTEM ${ZLIB_INCLUDE_DIR} )
 ENDIF ()
 
-INCLUDE_DIRECTORIES ( SYSTEM ${ILMBASE_INCLUDE_DIRS} )
-INCLUDE_DIRECTORIES ( SYSTEM ${OPENEXR_INCLUDE_DIRS} )
+INCLUDE_DIRECTORIES ( SYSTEM ${ILMBASE_LIBS_INCLUDE_DIRS} )
+INCLUDE_DIRECTORIES ( SYSTEM ${OPENEXR_LIBS_INCLUDE_DIRS} )
 INCLUDE_DIRECTORIES ( SYSTEM ${GLFW_INCLUDE_DIRECTORY} )
 
 IF (WIN32)
@@ -184,7 +185,7 @@
   ${Boost_IOSTREAMS_LIBRARY}
   ${Boost_SYSTEM_LIBRARY}
   ${Tbb_TBB_LIBRARY}
-  ${Ilmbase_HALF_LIBRARY}
+  ${ILMBASE_LIBS_LDFLAGS}
   ${ZLIB_LIBRARY}
   ${BLOSC_blosc_LIBRARY}
   )
@@ -192,7 +193,7 @@
   ${Boost_IOSTREAMS_LIBRARY}
   ${Boost_SYSTEM_LIBRARY}
   ${Tbb_TBB_LIBRARY}
-  ${Ilmbase_HALF_LIBRARY}
+  ${ILMBASE_LIBS_LDFLAGS}
   ${ZLIB_LIBRARY}
   ${BLOSC_blosc_LIBRARY}
   )
@@ -246,9 +247,8 @@
   openvdb_shared
   ${CMAKE_THREAD_LIBS_INIT}
   ${BLOSC_blosc_LIBRARY}
-  ${Openexr_ILMIMF_LIBRARY}
-  ${Ilmbase_ILMTHREAD_LIBRARY}
-  ${Ilmbase_IEX_LIBRARY}
+  ${OPENEXR_LIBS_LDFLAGS}
+  ${ILMBASE_LIBS_LDFLAGS}
   m
   stdc++
   )
diff -urN a/openvdb/python/CMakeLists.txt b/openvdb/python/CMakeLists.txt
--- a/openvdb/python/CMakeLists.txt	2018-08-28 12:20:33.000000000 +0100
+++ b/openvdb/python/CMakeLists.txt	2018-08-28 12:25:19.808755721 +0100
@@ -9,8 +9,8 @@
 IF ( NOT OPENVDB_BUILD_CORE )
   FIND_PACKAGE ( OpenVDB REQUIRED )
 
-  FIND_PACKAGE ( ILMBase REQUIRED )
-  FIND_PACKAGE ( OpenEXR REQUIRED )
+  PKG_CHECK_MODULES ( ILMBASE_LIBS REQUIRED IlmBase )
+  PKG_CHECK_MODULES ( OPENEXR_LIBS REQUIRED OpenEXR )
   FIND_PACKAGE ( Blosc REQUIRED )
   FIND_PACKAGE ( TBB REQUIRED )
   FIND_PACKAGE ( ZLIB REQUIRED )
@@ -29,8 +29,8 @@
   SET ( OPENVDB_LIB openvdb_shared)
 ENDIF ( NOT OPENVDB_BUILD_CORE )
 
-INCLUDE_DIRECTORIES ( SYSTEM ${ILMBASE_INCLUDE_DIRS} )
-INCLUDE_DIRECTORIES ( SYSTEM ${OPENEXR_INCLUDE_DIRS} )
+INCLUDE_DIRECTORIES ( SYSTEM ${ILMBASE_LIBS_INCLUDE_DIRS} )
+INCLUDE_DIRECTORIES ( SYSTEM ${OPENEXR_LIBS_INCLUDE_DIRS} )
 INCLUDE_DIRECTORIES ( SYSTEM ${Boost_INCLUDE_DIR} )
 INCLUDE_DIRECTORIES ( SYSTEM ${BLOSC_INCLUDE_DIR} )
 INCLUDE_DIRECTORIES ( SYSTEM ${TBB_INCLUDE_DIR} )
@@ -91,7 +91,7 @@
   ${GLEW_GLEW_LIBRARY}
   ${Boost_PYTHON_LIBRARY}
   ${PYTHON_LIBRARY}
-  ${Ilmbase_HALF_LIBRARY}
+  ${ILMBASE_LIBS_LDFLAGS}
   )
 
 SET_TARGET_PROPERTIES ( pyopenvdb PROPERTIES
