Build environment: fixes for Linux debug libraries build.
[blender.git] / build_files / build_environment / cmake / zlib.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 ExternalProject_Add(external_zlib
20         URL ${ZLIB_URI}
21         URL_HASH MD5=${ZLIB_HASH}
22         DOWNLOAD_DIR ${DOWNLOAD_DIR}
23         PREFIX ${BUILD_DIR}/zlib
24         CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=${LIBDIR}/zlib ${DEFAULT_CMAKE_FLAGS}
25         INSTALL_DIR ${LIBDIR}/zlib
26 )
27
28 if (WIN32)
29         if(BUILD_MODE STREQUAL Release)
30                 ExternalProject_Add_Step(external_zlib after_install
31                         COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/zlibstatic${LIBEXT} ${HARVEST_TARGET}/zlib/lib/libz_st${LIBEXT}
32                         COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/zlib/include/ ${HARVEST_TARGET}/zlib/include/
33                         DEPENDEES install
34                 )
35         endif()
36         if(BUILD_MODE STREQUAL Debug)
37                 ExternalProject_Add_Step(external_zlib after_install
38                 COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/zlibstaticd${LIBEXT} ${HARVEST_TARGET}/zlib/lib/libz_st_d${LIBEXT}
39                 DEPENDEES install
40                 )
41         endif()
42 else()
43         ExternalProject_Add_Step(external_zlib after_install
44                 COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/libz.a ${LIBDIR}/zlib/lib/libz_pic.a
45                 DEPENDEES install
46         )
47 endif()