svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22875:22935
[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 IF(WITH_INSTALL)
88
89   IF(UNIX)
90     ADD_CUSTOM_COMMAND(TARGET blender
91       POST_BUILD
92       MAIN_DEPENDENCY blender
93       #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/
94       #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
95     )
96   ENDIF(UNIX)
97
98   IF(UNIX AND NOT APPLE)
99     ADD_CUSTOM_COMMAND(
100       TARGET blender POST_BUILD 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     )
105     
106     IF(WITH_INTERNATIONAL)
107       ADD_CUSTOM_COMMAND(
108         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
109         COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/
110         COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/
111       )
112     ENDIF(WITH_INTERNATIONAL)
113     
114     IF(WITH_PYTHON)
115       ADD_CUSTOM_COMMAND(
116         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
117         COMMENT "copying blender scripts..."
118         COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/.blender/
119         COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/io ${TARGETDIR}/.blender/
120         COMMAND find ${TARGETDIR} -name "*.py?" -prune -exec rm -rf {} "\;"
121       )
122       
123       # Copy the systems python into the install directory
124       # Scons copy in tools/Blender.py
125       ADD_CUSTOM_COMMAND(
126         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
127         COMMENT "copying a subset of the systems python..."
128         
129         COMMAND mkdir ${TARGETDIR}/.blender/python # PYTHONPATH and PYTHONHOME is set here
130         COMMAND mkdir ${TARGETDIR}/.blender/python/lib/
131         COMMAND cp -R ${PYTHON_LIBPATH}/python${PYTHON_VERSION} ${TARGETDIR}/.blender/python/lib/
132         
133         COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/distutils
134         COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/lib2to3
135         COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/idlelib
136         COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/tkinter
137         COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/config
138         
139         COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/site-packages
140         COMMAND mkdir ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/site-packages    # python needs it.
141
142         COMMAND rm -f ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/lib-dynload/_tkinter.so
143         COMMAND find ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION} -name "test" -prune -exec rm -rf {} "\;"
144         COMMAND find ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION} -name "*.py?" -exec rm -rf {} "\;"
145         COMMAND find ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION} -name "*.so"-exec strip -s {} "\;"
146       )
147      
148     ENDIF(WITH_PYTHON)
149       
150     ADD_CUSTOM_COMMAND(
151       TARGET blender POST_BUILD MAIN_DEPENDENCY blender
152       COMMAND find ${TARGETDIR} -name .svn -prune -exec rm -rf {} "\;"
153     )
154     
155   ENDIF(UNIX AND NOT APPLE)
156
157   IF(APPLE)
158     SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
159     SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
160     SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
161
162     ADD_CUSTOM_COMMAND(
163       TARGET blender POST_BUILD MAIN_DEPENDENCY blender
164       COMMAND cp -R ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
165       COMMAND cp -R ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
166       COMMAND cp -R ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
167       COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
168       COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/.blender
169       COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
170       COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
171     )
172       
173     IF(WITH_INTERNATIONAL)
174       ADD_CUSTOM_COMMAND(
175         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
176         COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
177         COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/Resources/
178         COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
179         COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/Resources/
180       )
181     ENDIF(WITH_INTERNATIONAL)
182       
183     IF(WITH_PYTHON)
184       ADD_CUSTOM_COMMAND(
185         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
186         COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
187         COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/io ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
188         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/
189         COMMAND unzip -q ${LIBDIR}/release/python.zip -d ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/
190         COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;"
191       )
192     ENDIF(WITH_PYTHON)      
193     
194     ADD_CUSTOM_COMMAND(
195       TARGET blender POST_BUILD MAIN_DEPENDENCY blender    
196       COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
197       COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
198     )
199   ENDIF(APPLE)
200
201   IF(WIN32)
202     FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR)
203     
204     ADD_CUSTOM_COMMAND(TARGET blender
205       POST_BUILD
206       MAIN_DEPENDENCY blender
207       COMMAND if not exist \"${TARGETDIR}\\.blender\" mkdir \"${TARGETDIR}\\.blender\"
208       COMMAND if not exist \"${TARGETDIR}\\.blender\\locale\" mkdir \"${TARGETDIR}\\.blender\\locale\"
209       COMMAND if not exist \"${TARGETDIR}\\.blender\\ui\" mkdir \"${TARGETDIR}\\.blender\\ui\"
210       COMMAND if not exist \"${TARGETDIR}\\.blender\\io\" mkdir \"${TARGETDIR}\\.blender\\io\"
211       COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
212       COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" 
213       COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\"
214       COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\"
215       COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\.blender\\scripts\"
216       COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\ui\\*.*\" \"${TARGETDIR}\\.blender\\ui\"
217       COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\io\\*.*\" \"${TARGETDIR}\\.blender\\io\"
218       COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\plugins\"
219       COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\"
220       COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\windows\\extra\\python26.zip\" \"${TARGETDIR}\\\"
221     )
222     
223     FILE(TO_NATIVE_PATH "${LIBDIR}" WIN_LIBDIR)
224     
225     ADD_CUSTOM_COMMAND(TARGET blender
226       POST_BUILD
227       MAIN_DEPENDENCY blender
228       COMMAND copy /Y \"${WIN_LIBDIR}\\release\\python31.zip\" \"${TARGETDIR}\\\"
229       COMMAND copy /Y \"${WIN_LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\"
230       COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\"
231       COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
232       COMMAND copy /Y \"${WIN_LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
233       COMMAND copy /Y \"${WIN_LIBDIR}\\tiff\\lib\\libtiff.dll\" \"${TARGETDIR}\\\"
234       COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
235       COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
236       COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
237       COMMAND copy /Y \"${WIN_LIBDIR}\\samplerate\\lib\\libsamplerate-0.dll\" \"${TARGETDIR}\\\"
238     )
239
240     IF(WITH_INTERNATIONAL)
241       ADD_CUSTOM_COMMAND(TARGET blender
242         POST_BUILD
243         MAIN_DEPENDENCY blender
244         COMMAND copy /Y \"${WIN_LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
245       )
246     ENDIF(WITH_INTERNATIONAL)
247
248     IF(WITH_FFMPEG)
249       ADD_CUSTOM_COMMAND(TARGET blender
250         POST_BUILD
251         MAIN_DEPENDENCY blender
252         COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
253         COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
254         COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
255         COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
256         COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac-0.dll\" \"${TARGETDIR}\\\"
257         COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-2.dll\" \"${TARGETDIR}\\\"
258         COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"${TARGETDIR}\\\"
259         COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-67.dll\" \"${TARGETDIR}\\\"
260         COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
261         COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"${TARGETDIR}\\\"
262       )
263     ENDIF(WITH_FFMPEG)
264
265     IF(WITH_SNDFILE)
266       ADD_CUSTOM_COMMAND(TARGET blender
267         POST_BUILD
268         MAIN_DEPENDENCY blender
269         COMMAND copy /Y \"${WIN_LIBDIR}\\sndfile\\lib\\libsndfile-1.dll\" \"${TARGETDIR}\\\"
270       )
271     ENDIF(WITH_SNDFILE)
272
273     IF(WITH_JACK)
274       ADD_CUSTOM_COMMAND(TARGET blender
275         POST_BUILD
276         MAIN_DEPENDENCY blender
277         COMMAND copy /Y \"${WIN_LIBDIR}\\jack\\lib\\libjack.dll\" \"${TARGETDIR}\\\"
278       )
279     ENDIF(WITH_JACK)
280
281     IF(WITH_OPENAL)
282       ADD_CUSTOM_COMMAND(TARGET blender
283         POST_BUILD
284         MAIN_DEPENDENCY blender
285         COMMAND copy /Y \"${WIN_LIBDIR}\\openal\\lib\\OpenAL32.dll\" \"${TARGETDIR}\\\"
286         COMMAND copy /Y \"${WIN_LIBDIR}\\openal\\lib\\wrap_oal.dll\" \"${TARGETDIR}\\\"
287
288       )
289     ENDIF(WITH_OPENAL)
290
291
292   ENDIF(WIN32)
293 ENDIF(WITH_INSTALL)
294
295 ADD_DEPENDENCIES(blender makesdna)
296
297 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
298
299 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_editors blender_render)
300
301 IF(WITH_ELBEEM)
302   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} bf_elbeem)
303 ENDIF(WITH_ELBEEM)
304
305 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
306   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} extern_binreloc)
307 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
308
309 IF(UNIX)
310   # Sort libraries
311   SET(BLENDER_SORTED_LIBS
312     bf_windowmanager
313     bf_editors
314     bf_decimation 
315     blender_BSP 
316     bf_ghost 
317     bf_string 
318     blender_render 
319     blender_ONL 
320     bf_python 
321     bf_gen_python 
322     bf_blenkernel 
323     bf_nodes
324     bf_gpu
325     bf_blenloader 
326     bf_blenpluginapi 
327     bf_imbuf 
328     bf_blenlib 
329     bf_avi 
330     bf_cineon 
331     bf_openexr 
332     bf_dds
333     bf_readblenfile 
334     blender_bop 
335     bf_kernel 
336     bf_decimation 
337     bf_elbeem 
338     bf_IK 
339     bf_memutil 
340     bf_guardedalloc 
341     blender_CTR 
342     bf_moto 
343     bf_windowmanager
344     bf_editors
345     bf_blroutines 
346     bf_converter 
347     bf_dummy 
348     bf_bullet 
349     bf_smoke
350     bf_minilzo
351     bf_lzma
352     bf_common 
353     bf_ketsji 
354     bf_logic 
355     bf_rasterizer 
356     bf_oglrasterizer 
357     bf_expressions 
358     bf_scenegraph 
359     bf_moto 
360     bf_blroutines 
361     kx_network 
362     bf_kernel 
363     bf_ngnetwork 
364     extern_bullet 
365     bf_loopbacknetwork 
366     bf_common 
367     bf_moto 
368     bf_python
369     bf_gen_python
370     extern_binreloc
371     extern_glew
372     extern_libopenjpeg
373     bf_videotex
374     bf_rna
375     bf_dna
376     bf_blenfont
377     bf_audaspace
378   )
379
380   IF(WITH_CXX_GUARDEDALLOC)
381     SET(BLENDER_SORTED_LIBS ${BLENDER_SORTED_LIBS} bf_guardedalloc_cpp)
382   ENDIF(WITH_CXX_GUARDEDALLOC)
383
384   IF(WITH_QUICKTIME)
385     SET(BLENDER_SORTED_LIBS ${BLENDER_SORTED_LIBS} bf_quicktime)
386   ENDIF(WITH_QUICKTIME)
387
388
389   FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
390     SET(REMLIB ${SORTLIB})
391     FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
392       IF(${SEARCHLIB} STREQUAL ${SORTLIB})
393         SET(REMLIB "")
394       ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
395     ENDFOREACH(SEARCHLIB)
396     IF(REMLIB)
397       MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
398       LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
399     ENDIF(REMLIB)
400   ENDFOREACH(SORTLIB)
401   TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
402 ELSE(UNIX)
403   TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
404 ENDIF(UNIX)
405
406 SETUP_LIBLINKS(blender)