svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22205:22290
[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 cp -Rf ${CMAKE_SOURCE_DIR}/release/io ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
134     COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/
135     COMMAND unzip -q ${LIBDIR}/release/python.zip -d ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/
136     COMMAND find ${TARGETDIR}/blender.app -name CVS -prune -exec rm -rf {} "\;"
137     COMMAND find ${TARGETDIR}/blender.app -name CVS.sandboxinfo -prune -exec rm -rf {} "\;"
138     COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
139     COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
140   )
141 ENDIF(APPLE)
142
143 IF(WIN32)
144   FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR)
145   
146   ADD_CUSTOM_COMMAND(TARGET blender
147     POST_BUILD
148     MAIN_DEPENDENCY blender
149     COMMAND if not exist \"${TARGETDIR}\\.blender\" mkdir \"${TARGETDIR}\\.blender\"
150     COMMAND if not exist \"${TARGETDIR}\\.blender\\locale\" mkdir \"${TARGETDIR}\\.blender\\locale\"
151     COMMAND if not exist \"${TARGETDIR}\\.blender\\scripts\" mkdir \"${TARGETDIR}\\.blender\\scripts\"
152     COMMAND if not exist \"${TARGETDIR}\\.blender\\ui\" mkdir \"${TARGETDIR}\\.blender\\ui\"
153     COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
154     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" 
155     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\"
156     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\"
157     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\.blender\\scripts\"
158     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\ui\\*.*\" \"${TARGETDIR}\\.blender\\ui\"
159     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\plugins\"
160     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\"
161     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\windows\\extra\\python26.zip\" \"${TARGETDIR}\\\"
162   )
163   
164   FILE(TO_NATIVE_PATH "${LIBDIR}" WIN_LIBDIR)
165   
166   ADD_CUSTOM_COMMAND(TARGET blender
167     POST_BUILD
168     MAIN_DEPENDENCY blender
169     COMMAND copy /Y \"${WIN_LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\"
170     COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\"
171     COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
172     COMMAND copy /Y \"${WIN_LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
173     COMMAND copy /Y \"${WIN_LIBDIR}\\tiff\\lib\\libtiff.dll\" \"${TARGETDIR}\\\"
174     COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python26.dll\" \"${TARGETDIR}\\\"
175     COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python26_d.dll\" \"${TARGETDIR}\\\"
176     COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
177   )
178
179   IF(WITH_INTERNATIONAL)
180     ADD_CUSTOM_COMMAND(TARGET blender
181       POST_BUILD
182       MAIN_DEPENDENCY blender
183       COMMAND copy /Y \"${WIN_LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
184     )
185   ENDIF(WITH_INTERNATIONAL)
186
187   IF(WITH_FFMPEG)
188     ADD_CUSTOM_COMMAND(TARGET blender
189       POST_BUILD
190       MAIN_DEPENDENCY blender
191       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
192       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
193       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
194       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
195       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac-0.dll\" \"${TARGETDIR}\\\"
196       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-2.dll\" \"${TARGETDIR}\\\"
197       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"${TARGETDIR}\\\"
198       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-67.dll\" \"${TARGETDIR}\\\"
199       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
200       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"${TARGETDIR}\\\"
201     )
202   ENDIF(WITH_FFMPEG)
203 ENDIF(WIN32)
204
205 ADD_DEPENDENCIES(blender makesdna)
206
207 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
208
209 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_editors blender_render)
210
211 IF(WITH_ELBEEM)
212   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} bf_elbeem)
213 ENDIF(WITH_ELBEEM)
214
215 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
216   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} extern_binreloc)
217 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
218
219 IF(UNIX)
220   # Sort libraries
221   SET(BLENDER_SORTED_LIBS
222     bf_windowmanager
223         bf_editors
224     bf_decimation 
225     blender_BSP 
226     bf_ghost 
227     bf_string 
228     blender_render 
229     blender_ONL 
230     bf_python 
231     bf_gen_python 
232     bf_blenkernel 
233     bf_nodes
234         bf_gpu
235     bf_blenloader 
236     bf_blenpluginapi 
237     bf_imbuf 
238     bf_blenlib 
239     bf_avi 
240     bf_cineon 
241     bf_openexr 
242     bf_dds
243     bf_readblenfile 
244     blender_bop 
245     bf_kernel 
246     bf_decimation 
247     bf_elbeem 
248     bf_IK 
249     bf_memutil 
250     bf_guardedalloc 
251     blender_CTR 
252     bf_moto 
253     bf_windowmanager
254     bf_editors
255     bf_blroutines 
256     bf_converter 
257     bf_dummy 
258     bf_bullet 
259     bf_smoke
260     bf_common 
261     bf_ketsji 
262     bf_logic 
263     bf_rasterizer 
264     bf_oglrasterizer 
265     bf_expressions 
266     bf_scenegraph 
267     bf_moto 
268     bf_blroutines 
269     kx_network 
270     bf_kernel 
271     bf_ngnetwork 
272     extern_bullet 
273     bf_loopbacknetwork 
274     bf_common 
275     bf_moto 
276     bf_python
277     bf_gen_python
278     bf_quicktime
279     extern_binreloc
280     extern_glew
281     extern_libopenjpeg
282     bf_videotex
283     bf_rna
284     bf_dna
285     bf_blenfont
286     bf_soundsystem 
287   )
288
289   FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
290     SET(REMLIB ${SORTLIB})
291     FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
292       IF(${SEARCHLIB} STREQUAL ${SORTLIB})
293         SET(REMLIB "")
294       ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
295     ENDFOREACH(SEARCHLIB)
296     IF(REMLIB)
297       MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
298       LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
299     ENDIF(REMLIB)
300   ENDFOREACH(SORTLIB)
301   TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
302 ELSE(UNIX)
303   TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
304 ENDIF(UNIX)
305
306 SETUP_LIBLINKS(blender)