* cmake / mac - unzip python modules from /lib/release into .blender/python on build
[blender.git] / source / creator / CMakeLists.txt
1 # $Id$
2 # ***** BEGIN GPL LICENSE BLOCK *****
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 #
18 # The Original Code is Copyright (C) 2006, Blender Foundation
19 # All rights reserved.
20 #
21 # The Original Code is: all of this file.
22 #
23 # Contributor(s): Jacques Beaurain.
24 #
25 # ***** END GPL LICENSE BLOCK *****
26
27 SETUP_LIBDIRS()
28
29 INCLUDE_DIRECTORIES(../../intern/guardedalloc
30   ../blender/blenlib
31   ../blender/blenkernel
32   ../blender/editors/include
33   ../blender/makesrna
34   ../blender/makesrna/intern
35   ../blender/nodes
36   ../blender/include
37   ../blender/blenloader
38   ../blender/imbuf
39   ../blender/renderconverter
40   ../blender/render/extern/include
41   ../blender/makesdna
42   ../blender/gpu
43   ../blender/windowmanager
44   ../kernel/gen_messaging
45   ../kernel/gen_system
46   ../../extern/glew/include
47 )
48
49
50
51 IF(WITH_QUICKTIME)
52   ADD_DEFINITIONS(-DWITH_QUICKTIME)
53 ENDIF(WITH_QUICKTIME)
54
55 IF(WITH_OPENEXR)
56   ADD_DEFINITIONS(-DWITH_OPENEXR)
57 ENDIF(WITH_OPENEXR)
58
59 IF(WITH_PYTHON)
60   INCLUDE_DIRECTORIES(../blender/python)
61 ELSE(WITH_PYTHON)
62   ADD_DEFINITIONS(-DDISABLE_PYTHON)
63 ENDIF(WITH_PYTHON)
64
65 IF(NOT WITH_SDL)
66   ADD_DEFINITIONS(-DDISABLE_SDL)
67 ENDIF(NOT WITH_SDL)
68
69 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
70   ADD_DEFINITIONS(-DWITH_BINRELOC)
71   INCLUDE_DIRECTORIES(${BINRELOC_INC})
72 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
73
74 MESSAGE(STATUS "Configuring blender")
75
76 IF(WIN32)
77   ADD_EXECUTABLE(blender ${EXETYPE} creator.c ../icons/winblender.rc)
78 ELSE(WIN32)
79   ADD_EXECUTABLE(blender ${EXETYPE} creator.c)
80 ENDIF(WIN32)
81
82
83 # Post build steps for bundling/packaging.
84
85 SET(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
86
87
88 IF(UNIX)
89   ADD_CUSTOM_COMMAND(TARGET blender
90     POST_BUILD
91     MAIN_DEPENDENCY blender
92     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/
93     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
94   )
95 ENDIF(UNIX)
96
97 IF(UNIX AND NOT APPLE)
98   ADD_CUSTOM_COMMAND(TARGET blender
99     POST_BUILD
100     MAIN_DEPENDENCY blender
101     COMMAND rm -Rf ${TARGETDIR}/.blender
102     COMMAND mkdir ${TARGETDIR}/.blender/
103     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/
104     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/
105     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/
106     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/.blender/
107     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/.blender/
108     COMMAND find ${TARGETDIR} -name CVS -prune -exec rm -rf {} "\;"
109   )
110 ENDIF(UNIX AND NOT APPLE)
111
112 IF(APPLE)
113   SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
114   SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
115   SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
116
117   ADD_CUSTOM_COMMAND(TARGET blender
118     POST_BUILD
119     MAIN_DEPENDENCY blender
120     COMMAND cp -R ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
121     COMMAND cp -R ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
122     COMMAND cp -R ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
123     COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
124     COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/.blender
125     COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
126     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
127     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
128     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/Resources/
129     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
130     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/Resources/
131     COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
132     COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
133     COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/
134     COMMAND unzip -q ${LIBDIR}/release/python.zip -d ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/
135     COMMAND find ${TARGETDIR}/blender.app -name CVS -prune -exec rm -rf {} "\;"
136     COMMAND find ${TARGETDIR}/blender.app -name CVS.sandboxinfo -prune -exec rm -rf {} "\;"
137     COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
138     COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
139   )
140 ENDIF(APPLE)
141
142 IF(WIN32)
143   FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR)
144   
145   ADD_CUSTOM_COMMAND(TARGET blender
146     POST_BUILD
147     MAIN_DEPENDENCY blender
148     COMMAND if not exist \"${TARGETDIR}\\.blender\" mkdir \"${TARGETDIR}\\.blender\"
149     COMMAND if not exist \"${TARGETDIR}\\.blender\\locale\" mkdir \"${TARGETDIR}\\.blender\\locale\"
150     COMMAND if not exist \"${TARGETDIR}\\.blender\\scripts\" mkdir \"${TARGETDIR}\\.blender\\scripts\"
151     COMMAND if not exist \"${TARGETDIR}\\.blender\\ui\" mkdir \"${TARGETDIR}\\.blender\\ui\"
152     COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
153     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" 
154     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\"
155     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\"
156     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\.blender\\scripts\"
157     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\ui\\*.*\" \"${TARGETDIR}\\.blender\\ui\"
158     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\plugins\"
159     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\"
160     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\windows\\extra\\python26.zip\" \"${TARGETDIR}\\\"
161   )
162   
163   FILE(TO_NATIVE_PATH "${LIBDIR}" WIN_LIBDIR)
164   
165   ADD_CUSTOM_COMMAND(TARGET blender
166     POST_BUILD
167     MAIN_DEPENDENCY blender
168     COMMAND copy /Y \"${WIN_LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\"
169     COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\"
170     COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
171     COMMAND copy /Y \"${WIN_LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
172     COMMAND copy /Y \"${WIN_LIBDIR}\\tiff\\lib\\libtiff.dll\" \"${TARGETDIR}\\\"
173     COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python26.dll\" \"${TARGETDIR}\\\"
174     COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python26_d.dll\" \"${TARGETDIR}\\\"
175     COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
176   )
177
178   IF(WITH_INTERNATIONAL)
179     ADD_CUSTOM_COMMAND(TARGET blender
180       POST_BUILD
181       MAIN_DEPENDENCY blender
182       COMMAND copy /Y \"${WIN_LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
183     )
184   ENDIF(WITH_INTERNATIONAL)
185
186   IF(WITH_FFMPEG)
187     ADD_CUSTOM_COMMAND(TARGET blender
188       POST_BUILD
189       MAIN_DEPENDENCY blender
190       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
191       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
192       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
193       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
194       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac-0.dll\" \"${TARGETDIR}\\\"
195       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-2.dll\" \"${TARGETDIR}\\\"
196       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"${TARGETDIR}\\\"
197       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-67.dll\" \"${TARGETDIR}\\\"
198       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
199       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"${TARGETDIR}\\\"
200     )
201   ENDIF(WITH_FFMPEG)
202 ENDIF(WIN32)
203
204 ADD_DEPENDENCIES(blender makesdna)
205
206 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
207
208 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_editors blender_render)
209
210 IF(WITH_ELBEEM)
211   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} bf_elbeem)
212 ENDIF(WITH_ELBEEM)
213
214 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
215   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} extern_binreloc)
216 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
217
218 IF(UNIX)
219   # Sort libraries
220   SET(BLENDER_SORTED_LIBS
221     bf_windowmanager
222         bf_editors
223     bf_decimation 
224     blender_BSP 
225     bf_ghost 
226     bf_string 
227     blender_render 
228     blender_ONL 
229     bf_python 
230     bf_gen_python 
231     bf_blenkernel 
232     bf_nodes
233         bf_gpu
234     bf_blenloader 
235     bf_blenpluginapi 
236     bf_imbuf 
237     bf_blenlib 
238     bf_avi 
239     bf_cineon 
240     bf_openexr 
241     bf_dds
242     bf_readblenfile 
243     blender_bop 
244     bf_kernel 
245     bf_decimation 
246     bf_elbeem 
247     bf_IK 
248     bf_memutil 
249     bf_guardedalloc 
250     blender_CTR 
251     bf_moto 
252     bf_windowmanager
253     bf_editors
254     bf_blroutines 
255     bf_converter 
256     bf_dummy 
257     bf_bullet 
258     bf_common 
259     bf_ketsji 
260     bf_logic 
261     bf_rasterizer 
262     bf_oglrasterizer 
263     bf_expressions 
264     bf_scenegraph 
265     bf_moto 
266     bf_blroutines 
267     kx_network 
268     bf_kernel 
269     bf_ngnetwork 
270     extern_bullet 
271     bf_loopbacknetwork 
272     bf_common 
273     bf_moto 
274     bf_python
275     bf_gen_python
276     bf_quicktime
277     extern_binreloc
278     extern_glew
279     extern_libopenjpeg
280     bf_videotex
281     bf_rna
282     bf_dna
283     bf_blenfont
284     bf_soundsystem 
285   )
286
287   FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
288     SET(REMLIB ${SORTLIB})
289     FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
290       IF(${SEARCHLIB} STREQUAL ${SORTLIB})
291         SET(REMLIB "")
292       ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
293     ENDFOREACH(SEARCHLIB)
294     IF(REMLIB)
295       MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
296       LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
297     ENDIF(REMLIB)
298   ENDFOREACH(SORTLIB)
299   TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
300 ELSE(UNIX)
301   TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
302 ENDIF(UNIX)
303
304 SETUP_LIBLINKS(blender)