openvdb.cmake 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 Debug)
  19. set(BLOSC_POST _d)
  20. endif()
  21. set(OPENVDB_EXTRA_ARGS
  22. -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING}
  23. -DBoost_USE_MULTITHREADED=ON
  24. -DBoost_USE_STATIC_LIBS=ON
  25. -DBoost_USE_STATIC_RUNTIME=ON
  26. -DBOOST_ROOT=${LIBDIR}/boost
  27. -DBoost_NO_SYSTEM_PATHS=ON
  28. -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
  29. -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
  30. -DBLOSC_INCLUDE_DIR=${LIBDIR}/blosc/include/
  31. -DBLOSC_blosc_LIBRARY=${LIBDIR}/blosc/lib/libblosc${BLOSC_POST}${LIBEXT}
  32. -DOPENVDB_ENABLE_3_ABI_COMPATIBLE=OFF
  33. -DOPENVDB_BUILD_UNITTESTS=Off
  34. -DOPENVDB_BUILD_PYTHON_MODULE=Off
  35. -DGLEW_LOCATION=${LIBDIR}/glew/
  36. -DBLOSC_LOCATION=${LIBDIR}/blosc/
  37. -DTBB_LOCATION=${LIBDIR}/tbb/
  38. -DTBB_ROOT=${LIBDIR}/tbb/
  39. -DOPENEXR_LOCATION=${LIBDIR}/openexr
  40. -DILMBASE_LOCATION=${LIBDIR}/ilmbase
  41. -DIlmbase_HALF_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Half${ILMBASE_VERSION_POSTFIX}${LIBEXT}
  42. -DIlmbase_IEX_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Iex${ILMBASE_VERSION_POSTFIX}${LIBEXT}
  43. -DIlmbase_ILMTHREAD_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}IlmThread${ILMBASE_VERSION_POSTFIX}${LIBEXT}
  44. -DOpenexr_ILMIMF_LIBRARY=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf${OPENEXR_VERSION_POSTFIX}${LIBEXT}
  45. -DTBB_LIBRARYDIR=${LIBDIR}/tbb/lib
  46. -DTbb_TBB_LIBRARY=${LIBDIR}/tbb/lib/${LIBPREFIX}tbb_static${LIBEXT}
  47. -DTBB_LIBRARY_PATH=${LIBDIR}/tbb/lib
  48. )
  49. if(WIN32)
  50. # Namespaces seem to be buggy and cause linker errors due to things not
  51. # being in the correct namespace
  52. # needs to link pthreads due to it being a blosc dependency
  53. set(OPENVDB_EXTRA_ARGS ${OPENVDB_EXTRA_ARGS}
  54. -DOPENEXR_NAMESPACE_VERSIONING=OFF
  55. -DEXTRA_LIBS:FILEPATH=${LIBDIR}/pthreads/lib/pthreadVC3.lib
  56. )
  57. if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
  58. set(OPENVDB_EXTRA_ARGS ${OPENVDB_EXTRA_ARGS}
  59. -DCMAKE_SHARED_LINKER_FLAGS="/safeseh:no"
  60. -DCMAKE_EXE_LINKER_FLAGS="/safeseh:no"
  61. )
  62. endif()
  63. endif()
  64. ExternalProject_Add(openvdb
  65. URL ${OPENVDB_URI}
  66. DOWNLOAD_DIR ${DOWNLOAD_DIR}
  67. URL_HASH MD5=${OPENVDB_HASH}
  68. PREFIX ${BUILD_DIR}/openvdb
  69. PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb.diff
  70. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openvdb ${DEFAULT_CMAKE_FLAGS} ${OPENVDB_EXTRA_ARGS}
  71. INSTALL_DIR ${LIBDIR}/openvdb
  72. )
  73. add_dependencies(
  74. openvdb
  75. external_tbb
  76. external_boost
  77. external_ilmbase
  78. external_openexr
  79. external_zlib
  80. external_blosc
  81. )
  82. if(WIN32)
  83. if(BUILD_MODE STREQUAL Release)
  84. ExternalProject_Add_Step(openvdb after_install
  85. COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openvdb/include ${HARVEST_TARGET}/openvdb/include
  86. COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/libopenvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb.lib
  87. DEPENDEES install
  88. )
  89. endif()
  90. if(BUILD_MODE STREQUAL Debug)
  91. ExternalProject_Add_Step(openvdb after_install
  92. COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/libopenvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb_d.lib
  93. DEPENDEES install
  94. )
  95. endif()
  96. endif()