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