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