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