build_environment: fix mistaken commit in openexr.
[blender.git] / build_files / build_environment / cmake / openexr.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(WIN32)
20         set(OPENEXR_CMAKE_CXX_STANDARD_LIBRARIES "kernel32${LIBEXT} user32${LIBEXT} gdi32${LIBEXT} winspool${LIBEXT} shell32${LIBEXT} ole32${LIBEXT} oleaut32${LIBEXT} uuid${LIBEXT} comdlg32${LIBEXT} advapi32${LIBEXT} psapi${LIBEXT}")
21         set(OPENEXR_EXTRA_ARGS
22                 -DCMAKE_CXX_STANDARD_LIBRARIES=${OPENEXR_CMAKE_CXX_STANDARD_LIBRARIES}
23                 -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
24                 -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
25                 -DILMBASE_PACKAGE_PREFIX=${LIBDIR}/ilmbase
26                 -DOPENEXR_BUILD_ILMBASE=On
27                 -DOPENEXR_BUILD_OPENEXR=On
28                 -DOPENEXR_BUILD_PYTHON_LIBS=Off
29                 -DOPENEXR_BUILD_STATIC=On
30                 -DOPENEXR_BUILD_SHARED=Off
31                 -DOPENEXR_BUILD_TESTS=Off
32                 -DOPENEXR_BUILD_VIEWERS=Off
33                 -DOPENEXR_BUILD_UTILS=Off
34         )
35         ExternalProject_Add(external_openexr
36                 URL ${OPENEXR_URI}
37                 DOWNLOAD_DIR ${DOWNLOAD_DIR}
38                 URL_HASH MD5=${OPENEXR_HASH}
39                 PREFIX ${BUILD_DIR}/openexr
40                 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openexr ${DEFAULT_CMAKE_FLAGS} ${OPENEXR_EXTRA_ARGS}
41                 INSTALL_DIR ${LIBDIR}/openexr
42         )
43         
44         ExternalProject_Add_Step(external_openexr after_install
45                 COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openexr/lib ${HARVEST_TARGET}/openexr/lib
46                 #libs have moved between versions, just duplicate it for now. 
47                 COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openexr/lib ${HARVEST_TARGET}/ilmbase/lib
48                 COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openexr/include ${HARVEST_TARGET}/openexr/include 
49                 DEPENDEES install
50         )
51         
52 else()
53         set(OPENEXR_PKG_CONFIG_PATH ${LIBDIR}/zlib/share/pkgconfig)
54         set(OPENEXR_EXTRA_ARGS
55           --enable-static
56           --disable-shared
57           --enable-cxxstd=11
58           --with-ilmbase-prefix=${LIBDIR}/ilmbase
59           )
60
61         ExternalProject_Add(external_openexr
62                 URL ${OPENEXR_URI}
63                 DOWNLOAD_DIR ${DOWNLOAD_DIR}
64                 URL_HASH MD5=${OPENEXR_HASH}
65                 PREFIX ${BUILD_DIR}/openexr
66                 CONFIGURE_COMMAND ${CONFIGURE_ENV} && export PKG_CONFIG_PATH=${OPENEXR_PKG_CONFIG_PATH} && cd ${BUILD_DIR}/openexr/src/external_openexr/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/openexr ${OPENEXR_EXTRA_ARGS}
67                 BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/openexr/src/external_openexr/ && make -j${MAKE_THREADS}
68                 INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/openexr/src/external_openexr/ && make install
69                 INSTALL_DIR ${LIBDIR}/openexr
70         )
71 endif()
72
73 add_dependencies(
74         external_openexr
75         external_zlib
76         external_ilmbase
77 )