Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[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 ${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   ENDIF(WIN32)
265 ENDIF(WITH_INSTALL)
266
267 ADD_DEPENDENCIES(blender makesdna)
268
269 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
270
271 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_editors blender_render)
272
273 IF(WITH_ELBEEM)
274   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} bf_elbeem)
275 ENDIF(WITH_ELBEEM)
276
277 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
278   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} extern_binreloc)
279 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
280
281 IF(UNIX)
282   # Sort libraries
283   SET(BLENDER_SORTED_LIBS
284     bf_windowmanager
285     bf_editors
286     bf_decimation 
287     blender_BSP 
288     bf_ghost 
289     bf_string 
290     blender_render 
291     blender_ONL 
292     bf_python 
293     bf_gen_python 
294     bf_blenkernel 
295     bf_nodes
296     bf_gpu
297     bf_blenloader 
298     bf_blenpluginapi 
299     bf_imbuf 
300     bf_blenlib 
301     bf_avi 
302     bf_cineon 
303     bf_openexr 
304     bf_dds
305     bf_readblenfile 
306     blender_bop 
307     bf_kernel 
308     bf_decimation 
309     bf_elbeem 
310     bf_IK 
311     bf_memutil 
312     bf_guardedalloc 
313     blender_CTR 
314     bf_moto 
315     bf_windowmanager
316     bf_editors
317     bf_blroutines 
318     bf_converter 
319     bf_dummy 
320     bf_bullet 
321     bf_smoke
322     bf_common 
323     bf_ketsji 
324     bf_logic 
325     bf_rasterizer 
326     bf_oglrasterizer 
327     bf_expressions 
328     bf_scenegraph 
329     bf_moto 
330     bf_blroutines 
331     kx_network 
332     bf_kernel 
333     bf_ngnetwork 
334     extern_bullet 
335     bf_loopbacknetwork 
336     bf_common 
337     bf_moto 
338     bf_python
339     bf_gen_python
340     bf_quicktime
341     extern_binreloc
342     extern_glew
343     extern_libopenjpeg
344     bf_videotex
345     bf_rna
346     bf_dna
347     bf_blenfont
348     bf_audaspace
349   )
350
351   IF(WITH_CXX_GUARDEDALLOC)
352     SET(BLENDER_SORTED_LIBS ${BLENDER_SORTED_LIBS} bf_guardedalloc_cpp)
353   ENDIF(WITH_CXX_GUARDEDALLOC)
354
355   FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
356     SET(REMLIB ${SORTLIB})
357     FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
358       IF(${SEARCHLIB} STREQUAL ${SORTLIB})
359         SET(REMLIB "")
360       ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
361     ENDFOREACH(SEARCHLIB)
362     IF(REMLIB)
363       MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
364       LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
365     ENDIF(REMLIB)
366   ENDFOREACH(SORTLIB)
367   TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
368 ELSE(UNIX)
369   TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
370 ENDIF(UNIX)
371
372 SETUP_LIBLINKS(blender)