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