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