openimageio.cmake 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. # ***** BEGIN GPL LICENSE BLOCK *****
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ***** END GPL LICENSE BLOCK *****
  18. if(BUILD_MODE STREQUAL Release)
  19. set(OIIO_TOOLS ON)
  20. else()
  21. set(OIIO_TOOLS OFF)
  22. endif()
  23. if(UNIX AND NOT APPLE)
  24. # This causes linking to static pthread libraries which gives link errors.
  25. # Since we manually specify library paths it should static link other libs.
  26. set(OPENIMAGEIO_LINKSTATIC -DLINKSTATIC=OFF)
  27. else()
  28. set(OPENIMAGEIO_LINKSTATIC -DLINKSTATIC=ON)
  29. endif()
  30. if(WIN32)
  31. set(PNG_LIBNAME libpng16_static${LIBEXT})
  32. set(OIIO_SIMD_FLAGS -DUSE_SIMD=sse2 -DOPJ_STATIC=1)
  33. set(OPENJPEG_POSTFIX _msvc)
  34. else()
  35. set(PNG_LIBNAME libpng${LIBEXT})
  36. set(OIIO_SIMD_FLAGS)
  37. endif()
  38. if(WITH_WEBP)
  39. set(WEBP_ARGS
  40. -DWEBP_INCLUDE_DIR=${LIBDIR}/webp/include
  41. -DWEBP_LIBRARY=${LIBDIR}/webp/lib/${LIBPREFIX}webp${LIBEXT}
  42. )
  43. set(WEBP_DEP external_webp)
  44. endif()
  45. if(MSVC)
  46. set(OPENJPEG_FLAGS
  47. -DOPENJPEG_HOME=${LIBDIR}/openjpeg_msvc
  48. -DOPENJPEG_INCLUDE_DIR=${LIBDIR}/openjpeg_msvc/include/openjpeg-${OPENJPEG_SHORT_VERSION}
  49. -DOPENJPEG_LIBRARY=${LIBDIR}/openjpeg_msvc/lib/openjp2${LIBEXT}
  50. -DOPENJPEG_LIBRARY_DEBUG=${LIBDIR}/openjpeg_msvc/lib/openjp2${LIBEXT}
  51. )
  52. else()
  53. set(OPENJPEG_FLAGS
  54. -DOPENJPEG_INCLUDE_DIR=${LIBDIR}/openjpeg/include/openjpeg-${OPENJPEG_SHORT_VERSION}
  55. -DOPENJPEG_LIBRARY=${LIBDIR}/openjpeg/lib/${OPENJPEG_LIBRARY}
  56. )
  57. endif()
  58. set(OPENIMAGEIO_EXTRA_ARGS
  59. -DBUILDSTATIC=ON
  60. ${OPENIMAGEIO_LINKSTATIC}
  61. -DOPENEXR_INCLUDE_DIR=${LIBDIR}/openexr/include/openexr/
  62. -DOPENEXR_ILMIMF_LIBRARIES=${LIBDIR}/openexr/lib/IlmImf${OPENEXR_VERSION_POSTFIX}${LIBEXT}
  63. -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING}
  64. -DBoost_USE_MULTITHREADED=ON
  65. -DBoost_USE_STATIC_LIBS=ON
  66. -DBoost_USE_STATIC_RUNTIME=ON
  67. -DBOOST_ROOT=${LIBDIR}/boost
  68. -DBOOST_LIBRARYDIR=${LIBDIR}/boost/lib/
  69. -DBoost_NO_SYSTEM_PATHS=ON
  70. -OIIO_BUILD_CPP11=ON
  71. -DUSE_OPENGL=OFF
  72. -DUSE_TBB=OFF
  73. -DUSE_FIELD3D=OFF
  74. -DUSE_QT=OFF
  75. -DUSE_PYTHON=OFF
  76. -DUSE_GIF=OFF
  77. -DUSE_OPENCV=OFF
  78. -DUSE_OPENSSL=OFF
  79. -DUSE_OPENJPEG=ON
  80. -DUSE_FFMPEG=OFF
  81. -DUSE_PTEX=OFF
  82. -DUSE_FREETYPE=OFF
  83. -DUSE_LIBRAW=OFF
  84. -DUSE_PYTHON=OFF
  85. -DUSE_PYTHON3=OFF
  86. -DUSE_OCIO=OFF
  87. -DUSE_WEBP=${WITH_WEBP}
  88. -DOIIO_BUILD_TOOLS=${OIIO_TOOLS}
  89. -DOIIO_BUILD_TESTS=OFF
  90. -DBUILD_TESTING=OFF
  91. -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
  92. -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include
  93. -DPNG_LIBRARY=${LIBDIR}/png/lib/${PNG_LIBNAME}
  94. -DPNG_PNG_INCLUDE_DIR=${LIBDIR}/png/include
  95. -DTIFF_LIBRARY=${LIBDIR}/tiff/lib/${LIBPREFIX}tiff${LIBEXT}
  96. -DTIFF_INCLUDE_DIR=${LIBDIR}/tiff/include
  97. -DJPEG_LIBRARY=${LIBDIR}/jpg/lib/${JPEG_LIBRARY}
  98. -DJPEG_INCLUDE_DIR=${LIBDIR}/jpg/include
  99. ${OPENJPEG_FLAGS}
  100. -DOCIO_PATH=${LIBDIR}/opencolorio/
  101. -DOpenEXR_USE_STATIC_LIBS=On
  102. -DOPENEXR_HOME=${LIBDIR}/openexr/
  103. -DILMBASE_INCLUDE_PATH=${LIBDIR}/ilmbase/
  104. -DILMBASE_PACKAGE_PREFIX=${LIBDIR}/ilmbase/
  105. -DILMBASE_INCLUDE_DIR=${LIBDIR}/ilmbase/include/
  106. -DOPENEXR_HALF_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Half${ILMBASE_VERSION_POSTFIX}${LIBEXT}
  107. -DOPENEXR_IMATH_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Imath${ILMBASE_VERSION_POSTFIX}${LIBEXT}
  108. -DOPENEXR_ILMTHREAD_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}IlmThread${ILMBASE_VERSION_POSTFIX}${LIBEXT}
  109. -DOPENEXR_IEX_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Iex${ILMBASE_VERSION_POSTFIX}${LIBEXT}
  110. -DOPENEXR_INCLUDE_DIR=${LIBDIR}/openexr/include/
  111. -DOPENEXR_ILMIMF_LIBRARY=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf${OPENEXR_VERSION_POSTFIX}${LIBEXT}
  112. -DSTOP_ON_WARNING=OFF
  113. ${WEBP_FLAGS}
  114. ${OIIO_SIMD_FLAGS}
  115. )
  116. ExternalProject_Add(external_openimageio
  117. URL ${OPENIMAGEIO_URI}
  118. DOWNLOAD_DIR ${DOWNLOAD_DIR}
  119. URL_HASH MD5=${OPENIMAGEIO_HASH}
  120. PREFIX ${BUILD_DIR}/openimageio
  121. PATCH_COMMAND
  122. ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/src/include < ${PATCH_DIR}/openimageio_gdi.diff &&
  123. ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/openimageio_static_libs.diff
  124. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimageio ${DEFAULT_CMAKE_FLAGS} ${OPENIMAGEIO_EXTRA_ARGS}
  125. INSTALL_DIR ${LIBDIR}/openimageio
  126. )
  127. add_dependencies(
  128. external_openimageio
  129. external_png external_zlib
  130. external_ilmbase
  131. external_openexr
  132. external_jpeg
  133. external_boost
  134. external_tiff
  135. external_opencolorio
  136. external_openjpeg${OPENJPEG_POSTFIX}
  137. ${WEBP_DEP}
  138. )
  139. if(NOT WIN32)
  140. add_dependencies(
  141. external_openimageio
  142. external_opencolorio_extra
  143. )
  144. endif()