cmake option to disable SDL,
[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
88 IF(UNIX)
89   ADD_CUSTOM_COMMAND(TARGET blender
90     POST_BUILD
91     MAIN_DEPENDENCY blender
92     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/
93     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
94   )
95 ENDIF(UNIX)
96
97 IF(UNIX AND NOT APPLE)
98   ADD_CUSTOM_COMMAND(TARGET blender
99     POST_BUILD
100     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     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/
105     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/
106     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/.blender/
107     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/.blender/
108     COMMAND find ${TARGETDIR} -name CVS -prune -exec rm -rf {} "\;"
109   )
110 ENDIF(UNIX AND NOT APPLE)
111
112 IF(APPLE)
113   SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
114   SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
115   SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
116
117   ADD_CUSTOM_COMMAND(TARGET blender
118     POST_BUILD
119     MAIN_DEPENDENCY blender
120     COMMAND cp -R ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
121     COMMAND cp -R ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
122     COMMAND cp -R ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
123     COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
124     COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/.blender
125     COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
126     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
127     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
128     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/Resources/
129     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
130     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/Resources/
131     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
132     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
133     COMMAND find ${TARGETDIR}/blender.app -name CVS -prune -exec rm -rf {} "\;"
134     COMMAND find ${TARGETDIR}/blender.app -name CVS.sandboxinfo -prune -exec rm -rf {} "\;"
135     COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
136     COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
137   )
138 ENDIF(APPLE)
139
140 IF(WIN32)
141   FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR)
142   
143   ADD_CUSTOM_COMMAND(TARGET blender
144     POST_BUILD
145     MAIN_DEPENDENCY blender
146     COMMAND if not exist \"${TARGETDIR}\\.blender\" mkdir \"${TARGETDIR}\\.blender\"
147     COMMAND if not exist \"${TARGETDIR}\\.blender\\locale\" mkdir \"${TARGETDIR}\\.blender\\locale\"
148     COMMAND if not exist \"${TARGETDIR}\\.blender\\scripts\" mkdir \"${TARGETDIR}\\.blender\\scripts\"
149     COMMAND if not exist \"${TARGETDIR}\\.blender\\ui\" mkdir \"${TARGETDIR}\\.blender\\ui\"
150     COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
151     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" 
152     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\"
153     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\"
154     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\.blender\\scripts\"
155     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\ui\\*.*\" \"${TARGETDIR}\\.blender\\ui\"
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\\python26.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\\python26.dll\" \"${TARGETDIR}\\\"
172     COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python26_d.dll\" \"${TARGETDIR}\\\"
173     COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
174   )
175
176   IF(WITH_INTERNATIONAL)
177     ADD_CUSTOM_COMMAND(TARGET blender
178       POST_BUILD
179       MAIN_DEPENDENCY blender
180       COMMAND copy /Y \"${WIN_LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
181     )
182   ENDIF(WITH_INTERNATIONAL)
183
184   IF(WITH_FFMPEG)
185     ADD_CUSTOM_COMMAND(TARGET blender
186       POST_BUILD
187       MAIN_DEPENDENCY blender
188       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
189       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
190       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
191       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
192       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac-0.dll\" \"${TARGETDIR}\\\"
193       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-2.dll\" \"${TARGETDIR}\\\"
194       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"${TARGETDIR}\\\"
195       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-67.dll\" \"${TARGETDIR}\\\"
196       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
197       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"${TARGETDIR}\\\"
198     )
199   ENDIF(WITH_FFMPEG)
200 ENDIF(WIN32)
201
202 ADD_DEPENDENCIES(blender makesdna)
203
204 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
205
206 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_editors blender_render)
207
208 IF(WITH_ELBEEM)
209   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} bf_elbeem)
210 ENDIF(WITH_ELBEEM)
211
212 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
213   SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} extern_binreloc)
214 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
215
216 IF(UNIX)
217   # Sort libraries
218   SET(BLENDER_SORTED_LIBS
219     bf_windowmanager
220         bf_editors
221     bf_decimation 
222     blender_BSP 
223     bf_ghost 
224     bf_string 
225     blender_render 
226     blender_ONL 
227     bf_python 
228     bf_gen_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_IK 
246     bf_memutil 
247     bf_guardedalloc 
248     blender_CTR 
249     bf_moto 
250     bf_windowmanager
251     bf_editors
252     bf_blroutines 
253     bf_converter 
254     bf_dummy 
255     bf_bullet 
256     bf_common 
257     bf_ketsji 
258     bf_logic 
259     bf_rasterizer 
260     bf_oglrasterizer 
261     bf_expressions 
262     bf_scenegraph 
263     bf_moto 
264     bf_blroutines 
265     kx_network 
266     bf_kernel 
267     bf_ngnetwork 
268     extern_bullet 
269     bf_loopbacknetwork 
270     bf_common 
271     bf_moto 
272     bf_python
273     bf_gen_python
274     bf_quicktime
275     extern_binreloc
276     extern_glew
277     extern_libopenjpeg
278     bf_videotex
279     bf_rna
280     bf_dna
281     bf_blenfont
282     bf_soundsystem 
283   )
284
285   FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
286     SET(REMLIB ${SORTLIB})
287     FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
288       IF(${SEARCHLIB} STREQUAL ${SORTLIB})
289         SET(REMLIB "")
290       ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
291     ENDFOREACH(SEARCHLIB)
292     IF(REMLIB)
293       MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
294       LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
295     ENDIF(REMLIB)
296   ENDFOREACH(SORTLIB)
297   TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
298 ELSE(UNIX)
299   TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
300 ENDIF(UNIX)
301
302 SETUP_LIBLINKS(blender)