added FindOpenImageIO cmake module.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 18 Sep 2011 04:55:22 +0000 (04:55 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 18 Sep 2011 04:55:22 +0000 (04:55 +0000)
CMakeLists.txt
build_files/cmake/Modules/FindOpenImageIO.cmake [new file with mode: 0644]
build_files/cmake/macros.cmake
intern/cycles/CMakeLists.txt
intern/cycles/app/CMakeLists.txt

index a32742daf9c53c57850c8189574c228dd8782ea6..b08ee065e1a31abc795e9deb5aff8a81045e1c34 100644 (file)
@@ -522,17 +522,23 @@ if(UNIX AND NOT APPLE)
        endif()
 
        if(WITH_OPENIMAGEIO)
+
+               # temp, update
                if(CYCLES_OIIO)
-                       set(OPENIMAGEIO ${CYCLES_OIIO} CACHE PATH "OpenImageIO Directory")
+                       set(OPENIMAGEIO_ROOT_DIR ${CYCLES_OIIO})
                        unset(CYCLES_OIIO CACHE)
-               else()
-                       set(OPENIMAGEIO "/usr" CACHE PATH "OpenImageIO Directory")
                endif()
 
-               set(OPENIMAGEIO_INCLUDE_DIR ${OPENIMAGEIO}/include)
-               set(OPENIMAGEIO_LIBRARY OpenImageIO ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
-               set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
+               find_package(OpenImageIO)
+
+               set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
+               set(OPENIMAGEIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
                set(OPENIMAGEIO_DEFINITIONS)
+
+               if(NOT OPENIMAGEIO_FOUND)
+                       set(WITH_OPENIMAGEIO OFF)
+               endif()
+
        endif()
 
        # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
@@ -843,10 +849,10 @@ elseif(WIN32)
                endif()
                        
                if(WITH_OPENIMAGEIO)
-                       set(OPENIMAGEIO ${LIBDIR}/openimageio)
-                       set(OPENIMAGEIO_INCLUDE_DIR ${OPENIMAGEIO}/include)
-                       set(OPENIMAGEIO_LIBRARY OpenImageIO)
-                       set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
+                       set(OPENIMAGEIO_ROOT_DIR ${LIBDIR}/openimageio)
+                       set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_ROOT_DIR}/include)
+                       set(OPENIMAGEIO_LIBRARIES OpenImageIO)
+                       set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO_ROOT_DIR}/lib)
                        set(OPENIMAGEIO_DEFINITIONS)
                endif()
 
@@ -978,10 +984,10 @@ elseif(WIN32)
                endif()
                        
                if(WITH_OPENIMAGEIO)
-                       set(OPENIMAGEIO ${LIBDIR}/openimageio)
-                       set(OPENIMAGEIO_INCLUDE_DIR ${OPENIMAGEIO}/include)
-                       set(OPENIMAGEIO_LIBRARY OpenImageIO)
-                       set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
+                       set(OPENIMAGEIO_ROOT_DIR ${LIBDIR}/openimageio)
+                       set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_ROOT_DIR}/include)
+                       set(OPENIMAGEIO_LIBRARIES OpenImageIO)
+                       set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO_ROOT_DIR}/lib)
                        set(OPENIMAGEIO_DEFINITIONS)
                endif()
 
@@ -1205,9 +1211,9 @@ elseif(APPLE)
 
        if(WITH_OPENIMAGEIO)
                set(OPENIMAGEIO ${LIBDIR}/openimageio)
-               set(OPENIMAGEIO_INCLUDE_DIR ${OPENIMAGEIO}/include)
-               set(OPENIMAGEIO_LIBRARY OpenImageIO ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
-               set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib ${JPEG_LIBPATH} ${PNG_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH})
+               set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_ROOT_DIR}/include)
+               set(OPENIMAGEIO_LIBRARIES OpenImageIO ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
+               set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO_ROOT_DIR}/lib ${JPEG_LIBPATH} ${PNG_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH})
                set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
        endif()
 
@@ -1529,6 +1535,7 @@ if(FIRST_RUN)
        info_cfg_option(WITH_IMAGE_OPENJPEG)
        info_cfg_option(WITH_IMAGE_REDCODE)
        info_cfg_option(WITH_IMAGE_TIFF)
+       info_cfg_option(WITH_OPENIMAGEIO)
 
        info_cfg_text("Audio:")
        info_cfg_option(WITH_OPENAL)
diff --git a/build_files/cmake/Modules/FindOpenImageIO.cmake b/build_files/cmake/Modules/FindOpenImageIO.cmake
new file mode 100644 (file)
index 0000000..7512b93
--- /dev/null
@@ -0,0 +1,70 @@
+# - Find OpenImageIO library
+# Find the native OpenImageIO includes and library
+# This module defines
+#  OPENIMAGEIO_INCLUDE_DIRS, where to find openimageio.h, Set when
+#                            OPENIMAGEIO_INCLUDE_DIR is found.
+#  OPENIMAGEIO_LIBRARIES, libraries to link against to use OpenImageIO.
+#  OPENIMAGEIO_ROOT_DIR, The base directory to search for OpenImageIO.
+#                        This can also be an environment variable.
+#  OPENIMAGEIO_FOUND, If false, do not try to use OpenImageIO.
+#
+# also defined, but not for general use are
+#  OPENIMAGEIO_LIBRARY, where to find the OpenImageIO library.
+
+#=============================================================================
+# Copyright 2011 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# If OPENIMAGEIO_ROOT_DIR was defined in the environment, use it.
+IF(NOT OPENIMAGEIO_ROOT_DIR AND NOT $ENV{OPENIMAGEIO_ROOT_DIR} STREQUAL "")
+  SET(OPENIMAGEIO_ROOT_DIR $ENV{OPENIMAGEIO_ROOT_DIR})
+ENDIF()
+
+SET(_openimageio_SEARCH_DIRS
+  ${OPENIMAGEIO_ROOT_DIR}
+  /usr/local
+  /sw # Fink
+  /opt/local # DarwinPorts
+  /opt/csw # Blastwave
+)
+
+FIND_PATH(OPENIMAGEIO_INCLUDE_DIR
+  NAMES
+    OpenImageIO/imageio.h
+  HINTS
+    ${_openimageio_SEARCH_DIRS}
+  PATH_SUFFIXES
+    include
+)
+
+FIND_LIBRARY(OPENIMAGEIO_LIBRARY
+  NAMES
+    OpenImageIO
+  HINTS
+    ${_openimageio_SEARCH_DIRS}
+  PATH_SUFFIXES
+    lib64 lib
+  )
+
+# handle the QUIETLY and REQUIRED arguments and set OPENIMAGEIO_FOUND to TRUE if 
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenImageIO DEFAULT_MSG
+    OPENIMAGEIO_LIBRARY OPENIMAGEIO_INCLUDE_DIR)
+
+IF(OPENIMAGEIO_FOUND)
+  SET(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY})
+  SET(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_INCLUDE_DIR})
+ENDIF(OPENIMAGEIO_FOUND)
+
+MARK_AS_ADVANCED(
+  OPENIMAGEIO_INCLUDE_DIR
+  OPENIMAGEIO_LIBRARY
+)
index 236c20cf8d3e448d75806260c161ebf4ebedc3c7..9671bffe2bdc27fdf4f8c4678e6b4f94a1748098 100644 (file)
@@ -279,7 +279,7 @@ macro(setup_liblinks
                target_link_libraries(${target} ${TIFF_LIBRARY})
        endif()
        if(WITH_OPENIMAGEIO)
-               target_link_libraries(${target} ${OPENIMAGEIO_LIBRARY})
+               target_link_libraries(${target} ${OPENIMAGEIO_LIBRARIES})
        endif()
        if(WITH_BOOST)
                target_link_libraries(${target} ${BOOST_LIBRARIES})
index 0041f11c288475e09faa0aeb0b2bc650640a835a..d0b24c879a13b0a7621be037215be4d3346272a6 100644 (file)
@@ -59,8 +59,8 @@ add_definitions(-DWITH_MULTI)
 
 include_directories(
        ${BOOST_INCLUDE_DIR}
-       ${OPENIMAGEIO_INCLUDE_DIR}
-       ${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO)
+       ${OPENIMAGEIO_INCLUDE_DIRS}
+       ${OPENIMAGEIO_INCLUDE_DIRS}/OpenImageIO)
 
 # Subdirectories
 
index 4ef5fd6857db40831ec0a1aa1f7285537ed44750..ef6a80fbe5d2ff6a73c1fa8ea843ef45b5b8c61a 100644 (file)
@@ -19,7 +19,7 @@ set(LIBRARIES
        ${BOOST_LIBRARIES}
        ${OPENGL_LIBRARIES}
        ${CYCLES_GLEW_LIBRARY}
-       ${OPENIMAGEIO_LIBRARY})
+       ${OPENIMAGEIO_LIBRARIES})
 
 link_directories(${OPENIMAGEIO_LIBPATH} ${BOOST_LIBPATH})