4f11ea672d383cebd17cb4b703e2cefead29f017
[blender.git] / source / creator / CMakeLists.txt
1 # $Id$
2 # ***** BEGIN GPL/BL DUAL 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. The Blender
8 # Foundation also sells licenses for use in proprietary software under
9 # the Blender License.  See http://www.blender.org/BL/ for information
10 # about this.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software Foundation,
19 # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 #
21 # The Original Code is Copyright (C) 2006, Blender Foundation
22 # All rights reserved.
23 #
24 # The Original Code is: all of this file.
25 #
26 # Contributor(s): Jacques Beaurain.
27 #
28 # ***** END GPL/BL DUAL LICENSE BLOCK *****
29
30 SETUP_LIBDIRS()
31
32 INCLUDE_DIRECTORIES(../../intern/guardedalloc
33   ../blender/blenlib
34   ../blender/blenkernel
35   ../blender/nodes
36   ../blender/include
37   ../blender/blenloader
38   ../blender/imbuf
39   ../blender/renderconverter
40   ../blender/render/extern/include
41   ../blender/python
42   ../blender/makesdna
43   ../kernel/gen_messaging
44   ../kernel/gen_system
45   ../../extern/binreloc/include
46 )
47
48 IF(WITH_QUICKTIME)
49   ADD_DEFINITIONS(-DWITH_QUICKTIME)
50 ENDIF(WITH_QUICKTIME)
51
52 IF(WITH_BINRELOC)
53   ADD_DEFINITIONS(-DWITH_BINRELOC)
54 endif(WITH_BINRELOC)
55
56 IF(YESIAMSTUPID)
57   ADD_DEFINITIONS(-DYESIAMSTUPID)
58 ENDIF(YESIAMSTUPID)
59
60 MESSAGE(STATUS "Configuring blender")
61
62 ADD_CUSTOM_COMMAND(
63   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dna.c
64   COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna ${CMAKE_CURRENT_BINARY_DIR}/dna.c ${CMAKE_SOURCE_DIR}/source/blender/makesdna/
65   DEPENDS ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna
66 )
67
68 IF(WIN32)
69   ADD_EXECUTABLE(blender ${EXETYPE} creator.c ${CMAKE_CURRENT_BINARY_DIR}/dna.c ../icons/winblender.rc)
70 ELSE(WIN32)
71   ADD_EXECUTABLE(blender ${EXETYPE} creator.c ${CMAKE_CURRENT_BINARY_DIR}/dna.c)
72 ENDIF(WIN32)
73
74
75 # Post build steps for bundling/packaging.
76
77 SET(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
78
79
80 IF(UNIX)
81   ADD_CUSTOM_COMMAND(TARGET blender
82     POST_BUILD
83     MAIN_DEPENDENCY blender
84     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/
85     #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
86   )
87 ENDIF(UNIX)
88
89 IF(UNIX AND NOT APPLE)
90   ADD_CUSTOM_COMMAND(TARGET blender
91     POST_BUILD
92     MAIN_DEPENDENCY blender
93     COMMAND rm -Rf ${TARGETDIR}/.blender
94     COMMAND mkdir ${TARGETDIR}/.blender/
95     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/
96     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/
97     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/
98     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/.blender/
99     COMMAND find ${TARGETDIR} -name CVS -prune -exec rm -rf {} "\;"
100   )
101 ENDIF(UNIX AND NOT APPLE)
102
103 IF(APPLE)
104   SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
105   SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
106   SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
107
108   ADD_CUSTOM_COMMAND(TARGET blender
109     POST_BUILD
110     MAIN_DEPENDENCY blender
111     COMMAND cp -R ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
112     COMMAND cp -R ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
113     COMMAND cp -R ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
114     COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
115     COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/.blender
116     COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
117     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
118     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
119     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/Resources/
120     COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
121     COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/Resources/
122     COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/.blender/
123     COMMAND find ${TARGETDIR}/blender.app -name CVS -prune -exec rm -rf {} "\;"
124     COMMAND find ${TARGETDIR}/blender.app -name CVS.sandboxinfo -prune -exec rm -rf {} "\;"
125     COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
126   )
127 ENDIF(APPLE)
128
129 IF(WIN32)
130   FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR)
131   
132   ADD_CUSTOM_COMMAND(TARGET blender
133     POST_BUILD
134     MAIN_DEPENDENCY blender
135     COMMAND if not exist \"$\(TargetDir\)\\.blender\" mkdir \"$\(TargetDir\)\\.blender\"
136     COMMAND if not exist \"$\(TargetDir\)\\.blender\\locale\" mkdir \"$\(TargetDir\)\\.blender\\locale\"
137     COMMAND if not exist \"$\(TargetDir\)\\.blender\\scripts\" mkdir \"$\(TargetDir\)\\.blender\\scripts\"
138     COMMAND if not exist \"$\(TargetDir\)\\plugins\" mkdir \"$\(TargetDir\)\\plugins\"
139     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"$\(TargetDir\)\\.blender\\\"
140     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"$\(TargetDir\)\\.blender\\\"
141     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"$\(TargetDir\)\\.blender\\locale\"
142     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\scripts\\*.*\" \"$\(TargetDir\)\\.blender\\scripts\"
143     COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\plugins\\*.*\" \"$\(TargetDir\)\\plugins\"
144     COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\text\\*.*\" \"$\(TargetDir\)\"
145   )
146   
147   FILE(TO_NATIVE_PATH "${LIBDIR}" WIN_LIBDIR)
148   
149   ADD_CUSTOM_COMMAND(TARGET blender
150     POST_BUILD
151     MAIN_DEPENDENCY blender
152     COMMAND copy /Y \"${WIN_LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"$\(TargetDir\)\\\"
153     COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"$\(TargetDir\)\\\"
154     COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"$\(TargetDir\)\\\"
155     COMMAND copy /Y \"${WIN_LIBDIR}\\zlib\\lib\\zlib.dll\" \"$\(TargetDir\)\\\"
156     COMMAND copy /Y \"${WIN_LIBDIR}\\tiff\\lib\\libtiff.dll\" \"$\(TargetDir\)\\\"
157     COMMAND if $\(ConfigurationName\)==Debug copy /Y \"${WIN_LIBDIR}\\python\\lib\\python25_D.dll\" \"$\(TargetDir\)\\\"
158     COMMAND if $\(ConfigurationName\)==Debug copy /Y \"${WIN_LIBDIR}\\CRTL\\lib\\msvcrtd.dll\" \"$\(TargetDir\)\\\"
159     COMMAND if NOT $\(ConfigurationName\)==Debug 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-51.dll\" \"$\(TargetDir\)\\\"
177       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-49.dll\" \"$\(TargetDir\)\\\"
178       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libdts.dll\" \"$\(TargetDir\)\\\"
179       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac.dll\" \"$\(TargetDir\)\\\"
180       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad.dll\" \"$\(TargetDir\)\\\"
181       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libgsm.dll\" \"$\(TargetDir\)\\\"
182       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"$\(TargetDir\)\\\"
183       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libogg-0.dll\" \"$\(TargetDir\)\\\"
184       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libvorbis-0.dll\" \"$\(TargetDir\)\\\"
185       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libvorbisenc-2.dll\" \"$\(TargetDir\)\\\"
186       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-54.dll\" \"$\(TargetDir\)\\\"
187       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\postproc-51.dll\" \"$\(TargetDir\)\\\"
188       COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"$\(TargetDir\)\\\"
189     )
190   ENDIF(WITH_FFMPEG)
191 ENDIF(WIN32)
192
193 ADD_DEPENDENCIES(blender makesdna)
194
195 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
196
197 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} src blender_python blender_render blender_radiosity blender_IK bf_elbeem)
198
199 IF(UNIX)
200   # Sort libraries
201   SET(BLENDER_SORTED_LIBS
202     src 
203     bf_decimation 
204     blender_BSP 
205     bf_soundsystem 
206     bf_ghost 
207     bf_string 
208     blender_render 
209     blender_radiosity 
210     blender_ONL 
211     blender_python 
212     bf_blenkernel 
213     bf_nodes
214     bf_blenloader 
215     bf_blenpluginapi 
216     bf_imbuf 
217     bf_blenlib 
218     bf_avi 
219     bf_cineon 
220     bf_openexr 
221     bf_readblenfile 
222     blender_bop 
223     bf_kernel 
224     bf_decimation 
225     bf_elbeem 
226     bf_yafray 
227     blender_IK 
228     bf_memutil 
229     bf_guardedalloc 
230     blender_CTR 
231     bf_moto 
232     bf_bmfont 
233     verse 
234     src 
235     bf_ftfont 
236     extern_ftgl 
237     bf_blroutines 
238     bf_converter 
239     bf_dummy 
240     bf_bullet 
241     bf_common 
242     bf_ketsji 
243     bf_logic 
244     bf_rasterizer 
245     bf_oglrasterizer 
246     bf_expressions 
247     bf_scenegraph 
248     bf_moto 
249     bf_blroutines 
250     kx_network 
251     bf_kernel 
252     bf_ngnetwork 
253     extern_bullet 
254     bf_loopbacknetwork 
255     bf_sumo 
256     bf_common 
257     extern_solid 
258     extern_qhull 
259     bf_moto 
260     blender_python
261     bf_quicktime
262   )
263
264   FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
265     SET(REMLIB ${SORTLIB})
266     FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
267       IF(${SEARCHLIB} STREQUAL ${SORTLIB})
268         SET(REMLIB "")
269       ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
270     ENDFOREACH(SEARCHLIB)
271     IF(REMLIB)
272       MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
273       LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
274     ENDIF(REMLIB)
275   ENDFOREACH(SORTLIB)
276   TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
277 ELSE(UNIX)
278   TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
279 ENDIF(UNIX)
280
281 SETUP_LIBLINKS(blender)