2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r17434...
[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/nodes
33   ../blender/include
34   ../blender/blenloader
35   ../blender/imbuf
36   ../blender/renderconverter
37   ../blender/render/extern/include
38   ../blender/python
39   ../blender/makesdna
40   ../blender/gpu
41   ../blender/windowmanager
42   ../kernel/gen_messaging
43   ../kernel/gen_system
44   ../../extern/glew/include
45 )
46
47
48
49 IF(WITH_QUICKTIME)
50   ADD_DEFINITIONS(-DWITH_QUICKTIME)
51 ENDIF(WITH_QUICKTIME)
52
53 IF(WITH_OPENEXR)
54   ADD_DEFINITIONS(-DWITH_OPENEXR)
55 ENDIF(WITH_OPENEXR)
56
57 IF(LINUX)
58   ADD_DEFINITIONS(-DWITH_BINRELOC)
59   INCLUDE_DIRECTORIES(${BINRELOC_INC})
60 endif(LINUX)
61
62 MESSAGE(STATUS "Configuring blender")
63
64 ADD_CUSTOM_COMMAND(
65   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dna.c
66   COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna ${CMAKE_CURRENT_BINARY_DIR}/dna.c ${CMAKE_SOURCE_DIR}/source/blender/makesdna/
67   DEPENDS ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna
68   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rna.c
69   COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesrna ${CMAKE_CURRENT_BINARY_DIR}/rna.c ${CMAKE_SOURCE_DIR}/source/blender/makesrna/
70   DEPENDS ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesrna
71 )
72
73 IF(WIN32)
74   ADD_EXECUTABLE(blender ${EXETYPE} creator.c ${CMAKE_CURRENT_BINARY_DIR}/dna.c ${CMAKE_CURRENT_BINARY_DIR}/rna.c ../icons/winblender.rc)
75 ELSE(WIN32)
76   ADD_EXECUTABLE(blender ${EXETYPE} creator.c ${CMAKE_CURRENT_BINARY_DIR}/dna.c ${CMAKE_CURRENT_BINARY_DIR}/rna.c)
77 ENDIF(WIN32)
78
79
80 # Post build steps for bundling/packaging.
81
82 SET(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
83
84
85 IF(UNIX)
86   ADD_CUSTOM_COMMAND(TARGET blender
87     POST_BUILD
88     MAIN_DEPENDENCY blender
89     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/
90     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
91   )
92 ENDIF(UNIX)
93
94 IF(UNIX AND NOT APPLE)
95   ADD_CUSTOM_COMMAND(TARGET blender
96     POST_BUILD
97     MAIN_DEPENDENCY blender
98     COMMAND rm -Rf ${TARGETDIR}/.blender
99     COMMAND mkdir ${TARGETDIR}/.blender/
100     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/
101     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/
102     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/
103     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${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 find ${TARGETDIR}/blender.app -name CVS -prune -exec rm -rf {} "\;"
129     COMMAND find ${TARGETDIR}/blender.app -name CVS.sandboxinfo -prune -exec rm -rf {} "\;"
130     COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
131   )
132 ENDIF(APPLE)
133
134 IF(WIN32)
135   FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR)
136   
137   ADD_CUSTOM_COMMAND(TARGET blender
138     POST_BUILD
139     MAIN_DEPENDENCY blender
140     COMMAND if not exist \"${TARGETDIR}\\.blender\" mkdir \"${TARGETDIR}\\.blender\"
141     COMMAND if not exist \"${TARGETDIR}\\.blender\\locale\" mkdir \"${TARGETDIR}\\.blender\\locale\"
142     COMMAND if not exist \"${TARGETDIR}\\.blender\\scripts\" mkdir \"${TARGETDIR}\\.blender\\scripts\"
143     COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
144     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" 
145     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\"
146     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\"
147     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\.blender\\scripts\"
148     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\plugins\"
149     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\"
150     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\windows\\extra\\python25.zip\" \"${TARGETDIR}\\\"
151   )
152   
153   FILE(TO_NATIVE_PATH "${LIBDIR}" WIN_LIBDIR)
154   
155   ADD_CUSTOM_COMMAND(TARGET blender
156     POST_BUILD
157     MAIN_DEPENDENCY blender
158     COMMAND copy /Y \"${WIN_LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\"
159     COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\"
160     COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
161     COMMAND copy /Y \"${WIN_LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
162     COMMAND copy /Y \"${WIN_LIBDIR}\\tiff\\lib\\libtiff.dll\" \"${TARGETDIR}\\\"
163     COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python25.dll\" \"${TARGETDIR}\\\"
164     COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
165   )
166
167   IF(WITH_INTERNATIONAL)
168     ADD_CUSTOM_COMMAND(TARGET blender
169       POST_BUILD
170       MAIN_DEPENDENCY blender
171       COMMAND copy /Y \"${WIN_LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
172     )
173   ENDIF(WITH_INTERNATIONAL)
174
175   IF(WITH_FFMPEG)
176     ADD_CUSTOM_COMMAND(TARGET blender
177       POST_BUILD
178       MAIN_DEPENDENCY blender
179       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-51.dll\" \"${TARGETDIR}\\\"
180       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
181       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
182       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-49.dll\" \"${TARGETDIR}\\\"
183       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac-0.dll\" \"${TARGETDIR}\\\"
184       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-0.dll\" \"${TARGETDIR}\\\"
185       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"${TARGETDIR}\\\"
186       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-59.dll\" \"${TARGETDIR}\\\"
187       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
188       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"${TARGETDIR}\\\"
189     )
190   ENDIF(WITH_FFMPEG)
191 ENDIF(WIN32)
192
193 ADD_DEPENDENCIES(blender makesdna)
194
195 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
196
197 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_editors blender_render blender_radiosity)
198
199 IF(WITH_ELBEEM)
200   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} bf_elbeem)
201 ENDIF(WITH_ELBEEM)
202
203 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
204   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} extern_binreloc)
205 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
206
207 IF(UNIX)
208   # Sort libraries
209   SET(BLENDER_SORTED_LIBS
210     bf_windowmanager
211         bf_editors
212     bf_decimation 
213     blender_BSP 
214     bf_soundsystem 
215     bf_ghost 
216     bf_string 
217     blender_render 
218     blender_radiosity 
219     blender_ONL 
220     bf_python 
221     bf_blenkernel 
222     bf_nodes
223         bf_gpu
224     bf_blenloader 
225     bf_blenpluginapi 
226     bf_imbuf 
227     bf_blenlib 
228     bf_avi 
229     bf_cineon 
230     bf_openexr 
231     bf_dds
232     bf_readblenfile 
233     blender_bop 
234     bf_kernel 
235     bf_decimation 
236     bf_elbeem 
237     bf_yafray 
238     bf_IK 
239     bf_memutil 
240     bf_guardedalloc 
241     blender_CTR 
242     bf_moto 
243     bf_bmfont 
244     verse 
245     bf_windowmanager
246         bf_editors
247     bf_ftfont 
248     extern_ftgl 
249     bf_blroutines 
250     bf_converter 
251     bf_dummy 
252     bf_bullet 
253     bf_common 
254     bf_ketsji 
255     bf_logic 
256     bf_rasterizer 
257     bf_oglrasterizer 
258     bf_expressions 
259     bf_scenegraph 
260     bf_moto 
261     bf_blroutines 
262     kx_network 
263     bf_kernel 
264     bf_ngnetwork 
265     extern_bullet 
266     bf_loopbacknetwork 
267     bf_sumo 
268     bf_common 
269     extern_solid 
270     extern_qhull 
271     bf_moto 
272     bf_python
273     bf_quicktime
274     extern_binreloc
275     extern_glew
276     bf_videotex
277   )
278
279   FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
280     SET(REMLIB ${SORTLIB})
281     FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
282       IF(${SEARCHLIB} STREQUAL ${SORTLIB})
283         SET(REMLIB "")
284       ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
285     ENDFOREACH(SEARCHLIB)
286     IF(REMLIB)
287       MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
288       LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
289     ENDIF(REMLIB)
290   ENDFOREACH(SORTLIB)
291   TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
292 ELSE(UNIX)
293   TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
294 ENDIF(UNIX)
295
296 SETUP_LIBLINKS(blender)