svn merge -r 13415:13452 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / creator / CMakeLists.txt
1 # $Id$
2 # ***** BEGIN GPL/BL DUAL 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. The Blender
8 # Foundation also sells licenses for use in proprietary software under
9 # the Blender License.  See http://www.blender.org/BL/ for information
10 # about this.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software Foundation,
19 # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 #
21 # The Original Code is Copyright (C) 2006, Blender Foundation
22 # All rights reserved.
23 #
24 # The Original Code is: all of this file.
25 #
26 # Contributor(s): Jacques Beaurain.
27 #
28 # ***** END GPL/BL DUAL LICENSE BLOCK *****
29
30 SETUP_LIBDIRS()
31
32 INCLUDE_DIRECTORIES(../../intern/guardedalloc
33   ../blender/blenlib
34   ../blender/blenkernel
35   ../blender/nodes
36   ../blender/include
37   ../blender/blenloader
38   ../blender/imbuf
39   ../blender/renderconverter
40   ../blender/render/extern/include
41   ../blender/python
42   ../blender/makesdna
43   ../kernel/gen_messaging
44   ../kernel/gen_system
45 )
46
47
48
49 IF(WITH_QUICKTIME)
50   ADD_DEFINITIONS(-DWITH_QUICKTIME)
51 ENDIF(WITH_QUICKTIME)
52
53 IF(LINUX)
54   ADD_DEFINITIONS(-DWITH_BINRELOC)
55   INCLUDE_DIRECTORIES(${BINRELOC_INC})
56 endif(LINUX)
57
58 IF(YESIAMSTUPID)
59   ADD_DEFINITIONS(-DYESIAMSTUPID)
60 ENDIF(YESIAMSTUPID)
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 )
69
70 IF(WIN32)
71   ADD_EXECUTABLE(blender ${EXETYPE} creator.c ${CMAKE_CURRENT_BINARY_DIR}/dna.c ../icons/winblender.rc)
72 ELSE(WIN32)
73   ADD_EXECUTABLE(blender ${EXETYPE} creator.c ${CMAKE_CURRENT_BINARY_DIR}/dna.c)
74 ENDIF(WIN32)
75
76
77 # Post build steps for bundling/packaging.
78
79 SET(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
80
81
82 IF(UNIX)
83   ADD_CUSTOM_COMMAND(TARGET blender
84     POST_BUILD
85     MAIN_DEPENDENCY blender
86     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/
87     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
88   )
89 ENDIF(UNIX)
90
91 IF(UNIX AND NOT APPLE)
92   ADD_CUSTOM_COMMAND(TARGET blender
93     POST_BUILD
94     MAIN_DEPENDENCY blender
95     COMMAND rm -Rf ${TARGETDIR}/.blender
96     COMMAND mkdir ${TARGETDIR}/.blender/
97     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/
98     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/
99     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/
100     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/.blender/
101     COMMAND find ${TARGETDIR} -name CVS -prune -exec rm -rf {} "\;"
102   )
103 ENDIF(UNIX AND NOT APPLE)
104
105 IF(APPLE)
106   SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
107   SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
108   SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
109
110   ADD_CUSTOM_COMMAND(TARGET blender
111     POST_BUILD
112     MAIN_DEPENDENCY blender
113     COMMAND cp -R ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
114     COMMAND cp -R ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
115     COMMAND cp -R ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
116     COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
117     COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/.blender
118     COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
119     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
120     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
121     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/Resources/
122     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
123     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/Resources/
124     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
125     COMMAND find ${TARGETDIR}/blender.app -name CVS -prune -exec rm -rf {} "\;"
126     COMMAND find ${TARGETDIR}/blender.app -name CVS.sandboxinfo -prune -exec rm -rf {} "\;"
127     COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -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   )
148   
149   FILE(TO_NATIVE_PATH "${LIBDIR}" WIN_LIBDIR)
150   
151   ADD_CUSTOM_COMMAND(TARGET blender
152     POST_BUILD
153     MAIN_DEPENDENCY blender
154     COMMAND copy /Y \"${WIN_LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"$\(TargetDir\)\\\"
155     COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"$\(TargetDir\)\\\"
156     COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"$\(TargetDir\)\\\"
157     COMMAND copy /Y \"${WIN_LIBDIR}\\zlib\\lib\\zlib.dll\" \"$\(TargetDir\)\\\"
158     COMMAND copy /Y \"${WIN_LIBDIR}\\tiff\\lib\\libtiff.dll\" \"$\(TargetDir\)\\\"
159     COMMAND if $\(ConfigurationName\)==Debug copy /Y \"${WIN_LIBDIR}\\python\\lib\\python25_D.dll\" \"$\(TargetDir\)\\\"
160     COMMAND if $\(ConfigurationName\)==Debug copy /Y \"${WIN_LIBDIR}\\CRTL\\lib\\msvcrtd.dll\" \"$\(TargetDir\)\\\"
161     COMMAND if NOT $\(ConfigurationName\)==Debug copy /Y \"${WIN_LIBDIR}\\python\\lib\\python25.dll\" \"$\(TargetDir\)\\\"
162     COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"$\(TargetDir\)\\\"
163   )
164
165   IF(WITH_INTERNATIONAL)
166     ADD_CUSTOM_COMMAND(TARGET blender
167       POST_BUILD
168       MAIN_DEPENDENCY blender
169       COMMAND copy /Y \"${WIN_LIBDIR}\\iconv\\lib\\iconv.dll\" \"$\(TargetDir\)\\\"
170     )
171   ENDIF(WITH_INTERNATIONAL)
172
173   IF(WITH_FFMPEG)
174     ADD_CUSTOM_COMMAND(TARGET blender
175       POST_BUILD
176       MAIN_DEPENDENCY blender
177       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-51.dll\" \"$\(TargetDir\)\\\"
178       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-51.dll\" \"$\(TargetDir\)\\\"
179       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-49.dll\" \"$\(TargetDir\)\\\"
180       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libdts.dll\" \"$\(TargetDir\)\\\"
181       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac.dll\" \"$\(TargetDir\)\\\"
182       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad.dll\" \"$\(TargetDir\)\\\"
183       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libgsm.dll\" \"$\(TargetDir\)\\\"
184       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"$\(TargetDir\)\\\"
185       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libogg-0.dll\" \"$\(TargetDir\)\\\"
186       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libvorbis-0.dll\" \"$\(TargetDir\)\\\"
187       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libvorbisenc-2.dll\" \"$\(TargetDir\)\\\"
188       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-54.dll\" \"$\(TargetDir\)\\\"
189       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\postproc-51.dll\" \"$\(TargetDir\)\\\"
190       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"$\(TargetDir\)\\\"
191     )
192   ENDIF(WITH_FFMPEG)
193 ENDIF(WIN32)
194
195 ADD_DEPENDENCIES(blender makesdna)
196
197 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
198
199 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} src blender_python blender_render blender_radiosity blender_IK bf_elbeem)
200
201 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
202   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} extern_binreloc)
203 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
204
205 IF(UNIX)
206   # Sort libraries
207   SET(BLENDER_SORTED_LIBS
208     src 
209     bf_decimation 
210     blender_BSP 
211     bf_soundsystem 
212     bf_ghost 
213     bf_string 
214     blender_render 
215     blender_radiosity 
216     blender_ONL 
217     blender_python 
218     bf_blenkernel 
219     bf_nodes
220     bf_blenloader 
221     bf_blenpluginapi 
222     bf_imbuf 
223     bf_blenlib 
224     bf_avi 
225     bf_cineon 
226     bf_openexr 
227     bf_readblenfile 
228     blender_bop 
229     bf_kernel 
230     bf_decimation 
231     bf_elbeem 
232     bf_yafray 
233     blender_IK 
234     bf_memutil 
235     bf_guardedalloc 
236     blender_CTR 
237     bf_moto 
238     bf_bmfont 
239     verse 
240     src 
241     bf_ftfont 
242     extern_ftgl 
243     bf_blroutines 
244     bf_converter 
245     bf_dummy 
246     bf_bullet 
247     bf_common 
248     bf_ketsji 
249     bf_logic 
250     bf_rasterizer 
251     bf_oglrasterizer 
252     bf_expressions 
253     bf_scenegraph 
254     bf_moto 
255     bf_blroutines 
256     kx_network 
257     bf_kernel 
258     bf_ngnetwork 
259     extern_bullet 
260     bf_loopbacknetwork 
261     bf_sumo 
262     bf_common 
263     extern_solid 
264     extern_qhull 
265     bf_moto 
266     blender_python
267     bf_quicktime
268     extern_binreloc
269   )
270
271   FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
272     SET(REMLIB ${SORTLIB})
273     FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
274       IF(${SEARCHLIB} STREQUAL ${SORTLIB})
275         SET(REMLIB "")
276       ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
277     ENDFOREACH(SEARCHLIB)
278     IF(REMLIB)
279       MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
280       LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
281     ENDIF(REMLIB)
282   ENDFOREACH(SORTLIB)
283   TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
284 ELSE(UNIX)
285   TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
286 ENDIF(UNIX)
287
288 SETUP_LIBLINKS(blender)