Build Environment: fix alembic, openvdb, ffmpeg, osl build on Linux.
[blender.git] / build_files / build_environment / cmake / blosc.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 set(BLOSC_EXTRA_ARGS
20         -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
21         -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
22         -DBUILD_TESTS=OFF
23         -DBUILD_BENCHMARKS=OFF
24         -DCMAKE_DEBUG_POSTFIX=_d
25         -DThreads_FOUND=1
26         -DPTHREAD_LIBS=${LIBDIR}/pthreads/lib/pthreadVC2.lib
27         -DPTHREAD_INCLUDE_DIR=${LIBDIR}/pthreads/inc
28         -DDEACTIVATE_SNAPPY=ON
29         -DCMAKE_POSITION_INDEPENDENT_CODE=ON
30 )
31
32 if(WIN32)
33         #prevent blosc from including it's own local copy of zlib in the object file
34         #and cause linker errors with everybody else
35         set(BLOSC_EXTRA_ARGS ${BLOSC_EXTRA_ARGS}
36                 -DPREFER_EXTERNAL_ZLIB=ON
37         )
38 endif()
39
40 ExternalProject_Add(external_blosc
41         URL ${BLOSC_URI}
42         DOWNLOAD_DIR ${DOWNLOAD_DIR}
43         URL_HASH MD5=${BLOSC_HASH}
44         PREFIX ${BUILD_DIR}/blosc
45         PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/blosc/src/external_blosc < ${PATCH_DIR}/blosc.diff
46         CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/blosc ${DEFAULT_CMAKE_FLAGS} ${BLOSC_EXTRA_ARGS}
47         INSTALL_DIR ${LIBDIR}/blosc
48 )
49
50 add_dependencies(
51         external_blosc
52         external_zlib
53 )
54 if(WIN32)
55         add_dependencies(
56                 external_blosc
57                 external_pthreads
58         )
59 endif()
60
61 if (WIN32)
62         if(BUILD_MODE STREQUAL Release)
63                 ExternalProject_Add_Step(external_blosc after_install
64                         COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/blosc/lib/libblosc.lib ${HARVEST_TARGET}/blosc/lib/libblosc.lib
65                         COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/blosc/include/ ${HARVEST_TARGET}/blosc/include/
66                         DEPENDEES install
67                 )
68         endif()
69         if(BUILD_MODE STREQUAL Debug)
70                 ExternalProject_Add_Step(external_blosc after_install
71                         COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/blosc/lib/libblosc_d.lib ${HARVEST_TARGET}/blosc/lib/libblosc_d.lib
72                         DEPENDEES install
73                 )
74         endif()
75 endif()