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