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