build_environment: windows harvest cleanup.
[blender.git] / build_files / build_environment / cmake / harvest.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 ########################################################################
20 # Copy all generated files to the proper strucure as blender prefers
21 ########################################################################
22
23 if(NOT DEFINED HARVEST_TARGET)
24         set(HARVEST_TARGET ${CMAKE_CURRENT_SOURCE_DIR}/Harvest)
25 endif()
26 message("HARVEST_TARGET = ${HARVEST_TARGET}")
27
28 if(WIN32)
29 if(BUILD_MODE STREQUAL Release)
30         add_custom_target(Harvest_Release_Results
31                 COMMAND # jpeg rename libfile + copy include
32                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/jpg/lib/jpeg-static.lib ${HARVEST_TARGET}/jpeg/lib/libjpeg.lib &&
33                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/jpg/include/ ${HARVEST_TARGET}/jpeg/include/ &&
34                                 # pthreads, rename include dir
35                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/inc/ ${HARVEST_TARGET}/pthreads/include/ &&
36                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/lib/ ${HARVEST_TARGET}/pthreads/lib &&
37                                 # OpenImageIO
38                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/include ${HARVEST_TARGET}/OpenImageIO/include &&
39                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/lib ${HARVEST_TARGET}/OpenImageIO/lib &&
40                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/idiff.exe ${HARVEST_TARGET}/OpenImageIO/bin/idiff.exe &&
41                                 # png
42                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/png/lib/libpng16_static.lib ${HARVEST_TARGET}/png/lib/libpng.lib &&
43                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/png/include/ ${HARVEST_TARGET}/png/include/ &&
44                                 # freeglut-> opengl
45                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/freeglut/lib/freeglut_static.lib ${HARVEST_TARGET}/opengl/lib/freeglut_static.lib &&
46                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/freeglut/include/ ${HARVEST_TARGET}/opengl/include/ &&
47                                 # glew-> opengl
48                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/glew/lib/libglew32.lib ${HARVEST_TARGET}/opengl/lib/glew.lib &&
49                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/glew/include/ ${HARVEST_TARGET}/opengl/include/ &&
50                                 # sndfile
51                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/lib/libsndfile.dll.a ${HARVEST_TARGET}/sndfile/lib/libsndfile-1.lib &&
52                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/bin/libsndfile-1.dll ${HARVEST_TARGET}/sndfile/lib/libsndfile-1.dll &&
53                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/include/sndfile.h ${HARVEST_TARGET}/sndfile/include/sndfile.h &&
54                                 # tiff
55                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiff.lib ${HARVEST_TARGET}/tiff/lib/libtiff.lib &&
56                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tiff/include/ ${HARVEST_TARGET}/tiff/include/ &&
57                                 # Osl
58                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/osl/ ${HARVEST_TARGET}/osl &&
59                                 # BlendThumb
60                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/BlendThumb64/bin/blendthumb.dll ${HARVEST_TARGET}/ThumbHandler/lib/BlendThumb64.dll &&
61                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/BlendThumb32/bin/blendthumb.dll ${HARVEST_TARGET}/ThumbHandler/lib/BlendThumb.dll &&
62                                 # hidapi
63                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hidapi/ ${HARVEST_TARGET}/hidapi/ &&
64                                 # webp, straight up copy
65                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/webp ${HARVEST_TARGET}/webp
66                 DEPENDS
67         )
68 endif()
69
70 if(BUILD_MODE STREQUAL Debug)
71         add_custom_target(Harvest_Debug_Results
72                                 # OpenImageIO
73                 COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimageio/lib/OpenImageIO.lib ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_d.lib &&
74                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimageio/lib/OpenImageIO_Util.lib ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_Util_d.lib &&
75                                 # osl
76                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslcomp.lib ${HARVEST_TARGET}/osl/lib/oslcomp_d.lib &&
77                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslexec.lib ${HARVEST_TARGET}/osl/lib/oslexec_d.lib &&
78                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslquery.lib ${HARVEST_TARGET}/osl/lib/oslquery_d.lib &&
79                                 # python
80                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/python/ ${HARVEST_TARGET}/python/ &&
81                                 # hdf5
82                                 ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hdf5/lib ${HARVEST_TARGET}/hdf5/lib &&
83                                 # numpy
84                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}d.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}d.tar.gz &&
85                                 # python
86                                 ${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_d.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}_d.tar.gz
87                 DEPENDS Package_Python
88         )
89 endif()
90
91 else(WIN32)
92
93 function(harvest from to)
94         set(pattern "")
95         foreach(f ${ARGN})
96                 set(pattern ${f})
97         endforeach()
98
99         if(pattern STREQUAL "")
100                 get_filename_component(dirpath ${to} DIRECTORY)
101                 get_filename_component(filename ${to} NAME)
102                 install(
103                         FILES ${LIBDIR}/${from}
104                         DESTINATION ${HARVEST_TARGET}/${dirpath}
105                         RENAME ${filename})
106         else()
107                 install(
108                         DIRECTORY ${LIBDIR}/${from}/
109                         DESTINATION ${HARVEST_TARGET}/${to}
110                         USE_SOURCE_PERMISSIONS
111                         FILES_MATCHING PATTERN ${pattern}
112                         PATTERN "pkgconfig" EXCLUDE
113                         PATTERN "cmake" EXCLUDE
114                         PATTERN "clang" EXCLUDE
115                         PATTERN "__pycache__" EXCLUDE
116                         PATTERN "tests" EXCLUDE)
117         endif()
118 endfunction()
119
120 harvest(alembic/include alembic/include "*.h")
121 harvest(alembic/lib/libAlembic.a alembic/lib/libAlembic.a)
122 harvest(blosc/lib openvdb/lib "*.a")
123 harvest(boost/include boost/include "*")
124 harvest(boost/lib boost/lib "*.a")
125 harvest(ffmpeg/include ffmpeg/include "*.h")
126 harvest(ffmpeg/lib ffmpeg/lib "*.a")
127 harvest(fftw3/include fftw3/include "*.h")
128 harvest(fftw3/lib fftw3/lib "*.a")
129 harvest(flac/lib sndfile/lib "libFLAC.a")
130 harvest(freetype/include freetype/include "*.h")
131 harvest(freetype/lib/libfreetype2ST.a freetype/lib/libfreetype.a)
132 harvest(glew/include glew/include "*.h")
133 harvest(glew/lib glew/lib "*.a")
134 harvest(ilmbase openexr "*")
135 harvest(ilmbase/include openexr/include "*.h")
136 harvest(jemalloc/include jemalloc/include "*.h")
137 harvest(jemalloc/lib jemalloc/lib "*.a")
138 harvest(jpg/include jpeg/include "*.h")
139 harvest(jpg/lib jpeg/lib "libjpeg.a")
140 harvest(lame/lib ffmpeg/lib "*.a")
141 harvest(llvm/bin llvm/bin "llvm-config")
142 harvest(llvm/lib llvm/lib "libLLVM*.a")
143 harvest(ogg/lib ffmpeg/lib "*.a")
144 harvest(openal/include openal/include "*.h")
145 if(UNIX AND NOT APPLE)
146         harvest(openal/lib openal/lib "*.a")
147 endif()
148 harvest(opencollada/include/opencollada opencollada/include "*.h")
149 harvest(opencollada/lib/opencollada opencollada/lib "*.a")
150 harvest(opencolorio/include opencolorio/include "*.h")
151 harvest(opencolorio/lib opencolorio/lib "*.a")
152 harvest(opencolorio/lib/static opencolorio/lib "*.a")
153 harvest(openexr/include openexr/include "*.h")
154 harvest(openexr/lib openexr/lib "*.a")
155 harvest(openimageio/bin openimageio/bin "idiff")
156 harvest(openimageio/bin openimageio/bin "maketx")
157 harvest(openimageio/bin openimageio/bin "oiiotool")
158 harvest(openimageio/include openimageio/include "*")
159 harvest(openimageio/lib openimageio/lib "*.a")
160 harvest(openjpeg/include/openjpeg-2.3 openjpeg/include "*.h")
161 harvest(openjpeg/lib openjpeg/lib "*.a")
162 harvest(opensubdiv/include opensubdiv/include "*.h")
163 harvest(opensubdiv/lib opensubdiv/lib "*.a")
164 harvest(openvdb/include/openvdb openvdb/include/openvdb "*.h")
165 harvest(openvdb/lib openvdb/lib "*.a")
166 harvest(osl/bin osl/bin "oslc")
167 harvest(osl/include osl/include "*.h")
168 harvest(osl/lib osl/lib "*.a")
169 harvest(osl/shaders osl/shaders "*.h")
170 harvest(png/include png/include "*.h")
171 harvest(png/lib png/lib "*.a")
172 harvest(python/bin python/bin "python${PYTHON_SHORT_VERSION}m")
173 harvest(python/include python/include "*h")
174 harvest(python/lib python/lib "*")
175 harvest(sdl/include/SDL2 sdl/include "*.h")
176 harvest(sdl/lib sdl/lib "libSDL2.a")
177 harvest(sndfile/include sndfile/include "*.h")
178 harvest(sndfile/lib sndfile/lib "*.a")
179 harvest(spnav/include spnav/include "*.h")
180 harvest(spnav/lib spnav/lib "*.a")
181 harvest(tbb/include tbb/include "*.h")
182 harvest(tbb/lib/libtbb_static.a tbb/lib/libtbb.a)
183 harvest(theora/lib ffmpeg/lib "*.a")
184 harvest(tiff/include tiff/include "*.h")
185 harvest(tiff/lib tiff/lib "*.a")
186 harvest(vorbis/lib ffmpeg/lib "*.a")
187 harvest(vpx/lib ffmpeg/lib "*.a")
188 harvest(webp/lib ffmpeg/lib "*.a")
189 harvest(x264/lib ffmpeg/lib "*.a")
190 harvest(xml2/lib opencollada/lib "*.a")
191 harvest(xvidcore/lib ffmpeg/lib "*.a")
192
193 endif()