merging trunk 19093:19274
[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   )
128 ENDIF(APPLE)
129
130 IF(WIN32)
131   FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR)
132   
133   ADD_CUSTOM_COMMAND(TARGET blender
134     POST_BUILD
135     MAIN_DEPENDENCY blender
136     COMMAND if not exist \"${TARGETDIR}\\.blender\" mkdir \"${TARGETDIR}\\.blender\"
137     COMMAND if not exist \"${TARGETDIR}\\.blender\\locale\" mkdir \"${TARGETDIR}\\.blender\\locale\"
138     COMMAND if not exist \"${TARGETDIR}\\.blender\\scripts\" mkdir \"${TARGETDIR}\\.blender\\scripts\"
139     COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
140     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" 
141     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\"
142     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\"
143     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\.blender\\scripts\"
144     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\plugins\"
145     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\"
146     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\windows\\extra\\python25.zip\" \"${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 copy /Y \"${WIN_LIBDIR}\\python\\lib\\python25.dll\" \"${TARGETDIR}\\\"
160     COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
161   )
162
163   IF(WITH_INTERNATIONAL)
164     ADD_CUSTOM_COMMAND(TARGET blender
165       POST_BUILD
166       MAIN_DEPENDENCY blender
167       COMMAND copy /Y \"${WIN_LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
168     )
169   ENDIF(WITH_INTERNATIONAL)
170
171   IF(WITH_FFMPEG)
172     ADD_CUSTOM_COMMAND(TARGET blender
173       POST_BUILD
174       MAIN_DEPENDENCY blender
175       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-51.dll\" \"${TARGETDIR}\\\"
176       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
177       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
178       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-49.dll\" \"${TARGETDIR}\\\"
179       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac-0.dll\" \"${TARGETDIR}\\\"
180       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-0.dll\" \"${TARGETDIR}\\\"
181       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"${TARGETDIR}\\\"
182       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-59.dll\" \"${TARGETDIR}\\\"
183       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
184       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"${TARGETDIR}\\\"
185     )
186   ENDIF(WITH_FFMPEG)
187 ENDIF(WIN32)
188
189 ADD_DEPENDENCIES(blender makesdna)
190
191 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
192
193 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} src blender_python blender_render blender_radiosity)
194
195 IF(WITH_ELBEEM)
196   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} bf_elbeem)
197 ENDIF(WITH_ELBEEM)
198
199 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
200   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} extern_binreloc)
201 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
202
203 IF(UNIX)
204   # Sort libraries
205   SET(BLENDER_SORTED_LIBS
206     src 
207     bf_decimation 
208     blender_BSP 
209     bf_soundsystem 
210     bf_ghost 
211     bf_string 
212     blender_render 
213     blender_radiosity 
214     blender_ONL 
215     blender_python 
216     bf_blenkernel 
217     bf_nodes
218         bf_gpu
219     bf_blenloader 
220     bf_blenpluginapi 
221     bf_imbuf 
222     bf_blenlib 
223     bf_avi 
224     bf_cineon 
225     bf_openexr 
226     bf_dds
227     bf_readblenfile 
228     blender_bop 
229     bf_kernel 
230     bf_decimation 
231     bf_elbeem 
232     bf_yafray 
233     bf_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     extern_glew
270     extern_libopenjpeg
271     bf_videotex
272   )
273
274   FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
275     SET(REMLIB ${SORTLIB})
276     FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
277       IF(${SEARCHLIB} STREQUAL ${SORTLIB})
278         SET(REMLIB "")
279       ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
280     ENDFOREACH(SEARCHLIB)
281     IF(REMLIB)
282       MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
283       LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
284     ENDIF(REMLIB)
285   ENDFOREACH(SORTLIB)
286   TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
287 ELSE(UNIX)
288   TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
289 ENDIF(UNIX)
290
291 SETUP_LIBLINKS(blender)