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