CMake: Boost and OpenImageIO building support (unused still).
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 7 Nov 2011 15:44:09 +0000 (15:44 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 7 Nov 2011 15:44:09 +0000 (15:44 +0000)
CMakeLists.txt
build_files/cmake/macros.cmake

index 6bc409fe0df5d056beb1fb7c10da9a995999abfd..43f52eff0091d719be1ec1e0721ac9d9f97c6407 100644 (file)
@@ -491,6 +491,36 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
+       if(WITH_BOOST)
+               set(BOOST "/usr" CACHE PATH "Boost Directory")
+
+               if(NOT BOOST_CUSTOM)
+                       set(BOOST_ROOT ${BOOST})
+                       set(Boost_USE_MULTITHREADED ON)
+                       find_package(Boost 1.34 REQUIRED COMPONENTS filesystem regex system thread)
+               endif()
+
+               set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
+               set(BOOST_LIBRARIES ${Boost_LIBRARIES})
+               set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
+               set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
+       endif()
+
+       if(WITH_OPENIMAGEIO)
+               set(OPENIMAGEIO "/usr" CACHE PATH "OpenImageIO Directory")
+
+               set(OPENIMAGEIO_ROOT_DIR ${OPENIMAGEIO})
+               find_package(OpenImageIO REQUIRED)
+
+               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
        set(PLATFORM_LINKLIBS "-lutil -lc -lm -lpthread -lstdc++")
 
@@ -777,6 +807,28 @@ elseif(WIN32)
                        set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
                endif()
 
+               if(WITH_BOOST)
+                       set(BOOST ${LIBDIR}/boost)
+                       set(BOOST_INCLUDE_DIR ${BOOST}/include)
+                       set(BOOST_POSTFIX "vc90-mt-s-1_47.lib")
+                       set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_47.lib")
+                       set(BOOST_LIBRARIES
+                               optimized libboost_date_time-${BOOST_POSTFIX} libboost_filesystem-${BOOST_POSTFIX}
+                               libboost_regex-${BOOST_POSTFIX} libboost_system-${BOOST_POSTFIX} libboost_thread-${BOOST_POSTFIX}
+                               debug libboost_date_time-${BOOST_DEBUG_POSTFIX} libboost_filesystem-${BOOST_DEBUG_POSTFIX}
+                               libboost_regex-${BOOST_DEBUG_POSTFIX} libboost_system-${BOOST_DEBUG_POSTFIX} libboost_thread-${BOOST_DEBUG_POSTFIX})
+                       set(BOOST_LIBPATH ${BOOST}/lib)
+                       set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
+               endif()
+                       
+               if(WITH_OPENIMAGEIO)
+                       set(OPENIMAGEIO ${LIBDIR}/openimageio)
+                       set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
+                       set(OPENIMAGEIO_LIBRARIES OpenImageIO)
+                       set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
+                       set(OPENIMAGEIO_DEFINITIONS)
+               endif()
+
                set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
 
                # MSVC only, Mingw doesnt need
@@ -887,6 +939,28 @@ elseif(WIN32)
                        set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
                endif()
 
+               if(WITH_BOOST)
+                       set(BOOST ${LIBDIR}/boost)
+                       set(BOOST_INCLUDE_DIR ${BOOST}/include)
+                       set(BOOST_POSTFIX "vc90-mt-s-1_46_1")
+                       set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_46_1")
+                       set(BOOST_LIBRARIES
+                               optimized libboost_date_time-${BOOST_POSTFIX} libboost_filesystem-${BOOST_POSTFIX}
+                               libboost_regex-${BOOST_POSTFIX} libboost_system-${BOOST_POSTFIX} libboost_thread-${BOOST_POSTFIX}
+                               debug libboost_date_time-${BOOST_DEBUG_POSTFIX} libboost_filesystem-${BOOST_DEBUG_POSTFIX}
+                               libboost_regex-${BOOST_DEBUG_POSTFIX} libboost_system-${BOOST_DEBUG_POSTFIX} libboost_thread-${BOOST_DEBUG_POSTFIX})
+                       set(BOOST_LIBPATH ${BOOST}/lib)
+                       set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
+               endif()
+                       
+               if(WITH_OPENIMAGEIO)
+                       set(OPENIMAGEIO ${LIBDIR}/openimageio)
+                       set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
+                       set(OPENIMAGEIO_LIBRARIES OpenImageIO)
+                       set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
+                       set(OPENIMAGEIO_DEFINITIONS)
+               endif()
+
                set(PLATFORM_LINKFLAGS "--stack,2097152")
 
        endif()
@@ -1090,6 +1164,22 @@ elseif(APPLE)
                # linker needs "-weak_framework 3DconnexionClient"
        endif()
 
+       if(WITH_BOOST)
+               set(BOOST ${LIBDIR}/boost)
+               set(BOOST_INCLUDE_DIR ${BOOST}/include)
+               set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt)
+               set(BOOST_LIBPATH ${BOOST}/lib)
+               set(BOOST_DEFINITIONS)
+       endif()
+
+       if(WITH_OPENIMAGEIO)
+               set(OPENIMAGEIO ${LIBDIR}/openimageio)
+               set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
+               set(OPENIMAGEIO_LIBRARIES 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_DEFINITIONS "-DOIIO_STATIC_BUILD")
+       endif()
+
        set(EXETYPE MACOSX_BUNDLE)
 
        set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
index 10f89797754c13b7092c7f1ed0058f08a9a90cd3..ba1cdd9013bb54788a4c24b42c56289ba5458cdd 100644 (file)
@@ -165,6 +165,12 @@ macro(SETUP_LIBDIRS)
        if(WITH_IMAGE_TIFF)
                link_directories(${TIFF_LIBPATH})
        endif()
+       if(WITH_BOOST)
+               link_directories(${BOOST_LIBPATH})
+       endif()
+       if(WITH_OPENIMAGEIO)
+               link_directories(${OPENIMAGEIO_LIBPATH})
+       endif()
        if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE)
                link_directories(${OPENJPEG_LIBPATH})
        endif()
@@ -259,6 +265,12 @@ macro(setup_liblinks
        if(WITH_IMAGE_TIFF)
                target_link_libraries(${target} ${TIFF_LIBRARY})
        endif()
+       if(WITH_OPENIMAGEIO)
+               target_link_libraries(${target} ${OPENIMAGEIO_LIBRARIES})
+       endif()
+       if(WITH_BOOST)
+               target_link_libraries(${target} ${BOOST_LIBRARIES})
+       endif()
        if(WITH_IMAGE_OPENEXR)
                if(WIN32 AND NOT UNIX)
                        file_list_suffix(OPENEXR_LIBRARIES_DEBUG "${OPENEXR_LIBRARIES}" "_d")