svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r20849:20855
[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(LINUX)
66   ADD_DEFINITIONS(-DWITH_BINRELOC)
67   INCLUDE_DIRECTORIES(${BINRELOC_INC})
68 endif(LINUX)
69
70 MESSAGE(STATUS "Configuring blender")
71
72 IF(WIN32)
73   ADD_EXECUTABLE(blender ${EXETYPE} creator.c ../icons/winblender.rc)
74 ELSE(WIN32)
75   ADD_EXECUTABLE(blender ${EXETYPE} creator.c)
76 ENDIF(WIN32)
77
78
79 # Post build steps for bundling/packaging.
80
81 SET(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
82
83
84 IF(UNIX)
85   ADD_CUSTOM_COMMAND(TARGET blender
86     POST_BUILD
87     MAIN_DEPENDENCY blender
88     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/
89     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
90   )
91 ENDIF(UNIX)
92
93 IF(UNIX AND NOT APPLE)
94   ADD_CUSTOM_COMMAND(TARGET blender
95     POST_BUILD
96     MAIN_DEPENDENCY blender
97     COMMAND rm -Rf ${TARGETDIR}/.blender
98     COMMAND mkdir ${TARGETDIR}/.blender/
99     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/
100     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/
101     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/
102     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/.blender/
103     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/.blender/
104     COMMAND find ${TARGETDIR} -name CVS -prune -exec rm -rf {} "\;"
105   )
106 ENDIF(UNIX AND NOT APPLE)
107
108 IF(APPLE)
109   SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
110   SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
111   SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
112
113   ADD_CUSTOM_COMMAND(TARGET blender
114     POST_BUILD
115     MAIN_DEPENDENCY blender
116     COMMAND cp -R ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
117     COMMAND cp -R ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
118     COMMAND cp -R ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
119     COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
120     COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/.blender
121     COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
122     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
123     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
124     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/Resources/
125     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
126     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/Resources/
127     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
128     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
129     COMMAND find ${TARGETDIR}/blender.app -name CVS -prune -exec rm -rf {} "\;"
130     COMMAND find ${TARGETDIR}/blender.app -name CVS.sandboxinfo -prune -exec rm -rf {} "\;"
131     COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
132     COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
133   )
134 ENDIF(APPLE)
135
136 IF(WIN32)
137   FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR)
138   
139   ADD_CUSTOM_COMMAND(TARGET blender
140     POST_BUILD
141     MAIN_DEPENDENCY blender
142     COMMAND if not exist \"${TARGETDIR}\\.blender\" mkdir \"${TARGETDIR}\\.blender\"
143     COMMAND if not exist \"${TARGETDIR}\\.blender\\locale\" mkdir \"${TARGETDIR}\\.blender\\locale\"
144     COMMAND if not exist \"${TARGETDIR}\\.blender\\scripts\" mkdir \"${TARGETDIR}\\.blender\\scripts\"
145     COMMAND if not exist \"${TARGETDIR}\\.blender\\ui\" mkdir \"${TARGETDIR}\\.blender\\ui\"
146     COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
147     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" 
148     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\"
149     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\"
150     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\.blender\\scripts\"
151     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\ui\\*.*\" \"${TARGETDIR}\\.blender\\ui\"
152     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\plugins\"
153     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\"
154     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\windows\\extra\\python25.zip\" \"${TARGETDIR}\\\"
155   )
156   
157   FILE(TO_NATIVE_PATH "${LIBDIR}" WIN_LIBDIR)
158   
159   ADD_CUSTOM_COMMAND(TARGET blender
160     POST_BUILD
161     MAIN_DEPENDENCY blender
162     COMMAND copy /Y \"${WIN_LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\"
163     COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\"
164     COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
165     COMMAND copy /Y \"${WIN_LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
166     COMMAND copy /Y \"${WIN_LIBDIR}\\tiff\\lib\\libtiff.dll\" \"${TARGETDIR}\\\"
167     COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python25.dll\" \"${TARGETDIR}\\\"
168     COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
169   )
170
171   IF(WITH_INTERNATIONAL)
172     ADD_CUSTOM_COMMAND(TARGET blender
173       POST_BUILD
174       MAIN_DEPENDENCY blender
175       COMMAND copy /Y \"${WIN_LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
176     )
177   ENDIF(WITH_INTERNATIONAL)
178
179   IF(WITH_FFMPEG)
180     ADD_CUSTOM_COMMAND(TARGET blender
181       POST_BUILD
182       MAIN_DEPENDENCY blender
183       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
184       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
185       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
186       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
187       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac-0.dll\" \"${TARGETDIR}\\\"
188       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-2.dll\" \"${TARGETDIR}\\\"
189       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"${TARGETDIR}\\\"
190       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-67.dll\" \"${TARGETDIR}\\\"
191       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
192       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"${TARGETDIR}\\\"
193     )
194   ENDIF(WITH_FFMPEG)
195 ENDIF(WIN32)
196
197 ADD_DEPENDENCIES(blender makesdna)
198
199 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
200
201 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_editors blender_render blender_radiosity)
202
203 IF(WITH_ELBEEM)
204   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} bf_elbeem)
205 ENDIF(WITH_ELBEEM)
206
207 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
208   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} extern_binreloc)
209 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
210
211 IF(UNIX)
212   # Sort libraries
213   SET(BLENDER_SORTED_LIBS
214     bf_windowmanager
215         bf_editors
216     bf_decimation 
217     blender_BSP 
218     bf_ghost 
219     bf_string 
220     blender_render 
221     blender_radiosity 
222     blender_ONL 
223     bf_python 
224     bf_blenkernel 
225     bf_nodes
226         bf_gpu
227     bf_blenloader 
228     bf_blenpluginapi 
229     bf_imbuf 
230     bf_blenlib 
231     bf_avi 
232     bf_cineon 
233     bf_openexr 
234     bf_dds
235     bf_readblenfile 
236     blender_bop 
237     bf_kernel 
238     bf_decimation 
239     bf_elbeem 
240     bf_yafray 
241     bf_IK 
242     bf_memutil 
243     bf_guardedalloc 
244     blender_CTR 
245     bf_moto 
246     bf_windowmanager
247     bf_editors
248     bf_blroutines 
249     bf_converter 
250     bf_dummy 
251     bf_bullet 
252     bf_common 
253     bf_ketsji 
254     bf_logic 
255     bf_rasterizer 
256     bf_oglrasterizer 
257     bf_expressions 
258     bf_scenegraph 
259     bf_moto 
260     bf_blroutines 
261     kx_network 
262     bf_kernel 
263     bf_ngnetwork 
264     extern_bullet 
265     bf_loopbacknetwork 
266     bf_sumo 
267     bf_common 
268     extern_solid 
269     extern_qhull 
270     bf_moto 
271     bf_python
272     bf_quicktime
273     extern_binreloc
274     extern_glew
275     extern_libopenjpeg
276     bf_videotex
277     bf_rna
278     bf_dna
279     bf_blenfont
280     bf_soundsystem 
281   )
282
283   FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
284     SET(REMLIB ${SORTLIB})
285     FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
286       IF(${SEARCHLIB} STREQUAL ${SORTLIB})
287         SET(REMLIB "")
288       ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
289     ENDFOREACH(SEARCHLIB)
290     IF(REMLIB)
291       MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
292       LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
293     ENDIF(REMLIB)
294   ENDFOREACH(SORTLIB)
295   TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
296 ELSE(UNIX)
297   TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
298 ENDIF(UNIX)
299
300 SETUP_LIBLINKS(blender)