Add option for CMake to build libredcode, also use CODEC prefix for ffmpeg, quicktime...
[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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 # So BUILDINFO and BLENDERPATH strings are automatically quoted
28 CMAKE_POLICY(SET CMP0005 NEW)
29
30 SETUP_LIBDIRS()
31
32 INCLUDE_DIRECTORIES(
33         ../../intern/guardedalloc
34         ../blender/blenlib
35         ../blender/blenkernel
36         ../blender/editors/include
37         ../blender/makesrna
38         ../blender/imbuf
39         ../blender/render/extern/include
40         ../blender/makesdna
41         ../blender/gpu
42         ../blender/windowmanager
43 )
44
45 IF(WITH_CODEC_QUICKTIME)
46         ADD_DEFINITIONS(-DWITH_QUICKTIME)
47 ENDIF(WITH_CODEC_QUICKTIME)
48
49 IF(WITH_IMAGE_OPENEXR)
50         ADD_DEFINITIONS(-DWITH_OPENEXR)
51 ENDIF(WITH_IMAGE_OPENEXR)
52
53 IF(WITH_IMAGE_TIFF)
54         ADD_DEFINITIONS(-DWITH_TIFF)
55 ENDIF(WITH_IMAGE_TIFF)
56
57 IF(WITH_IMAGE_DDS)
58         ADD_DEFINITIONS(-DWITH_DDS)
59 ENDIF(WITH_IMAGE_DDS)
60
61 IF(WITH_IMAGE_CINEON)
62         ADD_DEFINITIONS(-DWITH_CINEON)
63 ENDIF(WITH_IMAGE_CINEON)
64
65 IF(WITH_IMAGE_HDR)
66         ADD_DEFINITIONS(-DWITH_HDR)
67 ENDIF(WITH_IMAGE_HDR)
68
69 IF(WITH_PYTHON)
70         INCLUDE_DIRECTORIES(../blender/python)
71         ADD_DEFINITIONS(-DWITH_PYTHON)
72 ENDIF(WITH_PYTHON)
73
74 IF(WITH_GAMEENGINE)
75         INCLUDE_DIRECTORIES(
76                 ../kernel/gen_messaging
77                 ../kernel/gen_system
78         )
79
80         ADD_DEFINITIONS(-DWITH_GAMEENGINE)
81 ENDIF(WITH_GAMEENGINE)
82
83 IF(NOT WITH_SDL)
84         ADD_DEFINITIONS(-DDISABLE_SDL)
85 ENDIF(NOT WITH_SDL)
86
87 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
88         ADD_DEFINITIONS(-DWITH_BINRELOC)
89         INCLUDE_DIRECTORIES(${BINRELOC_INC})
90 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
91
92 # Setup the exe sources and buildinfo
93 SET(SRC
94         creator.c
95 )
96
97 IF(WIN32 AND NOT UNIX)
98         LIST(APPEND SRC
99                 ../icons/winblender.rc
100         )
101 ENDIF(WIN32 AND NOT UNIX)
102
103 IF(WITH_BUILDINFO)
104         STRING(REPLACE " " "\ " BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}")
105         STRING(REPLACE " " "\ " BUILDINFO_CXXFLAGS "${CMAKE_CXX_FLAGS}")
106         STRING(REPLACE " " "\ " BUILDINFO_LINKFLAGS "${PLATFORM_LINKFLAGS}")
107         ADD_DEFINITIONS(
108                 -DBUILD_DATE="${BUILD_DATE}"
109                 -DBUILD_TIME="${BUILD_TIME}"
110                 -DBUILD_REV="${BUILD_REV}"
111                 -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
112                 -DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
113                 -DBUILD_CFLAGS="${BUILDINFO_CFLAGS}"
114                 -DBUILD_CXXFLAGS="${BUILDINFO_CXXFLAGS}"
115                 -DBUILD_LINKFLAGS="${BUILDINFO_LINKFLAGS}"
116                 -DBUILD_SYSTEM="CMake"
117         )
118
119         LIST(APPEND SRC
120                 buildinfo.c
121         )
122 ENDIF(WITH_BUILDINFO)
123
124 MESSAGE(STATUS "Configuring blender")
125
126 ADD_EXECUTABLE(blender ${EXETYPE} ${SRC})
127
128 # Post build steps for bundling/packaging.
129
130 SET(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
131
132 IF(WITH_INSTALL)
133
134         IF(UNIX)
135                 ADD_CUSTOM_COMMAND(TARGET blender
136                         POST_BUILD
137                         MAIN_DEPENDENCY blender
138                         #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/
139                         #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
140                 )
141         ENDIF(UNIX)
142
143         IF(UNIX AND NOT APPLE)
144                 
145                 # Local installation, "make install" can be done after this optionally
146                 
147                 ADD_CUSTOM_COMMAND(
148                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
149                         COMMAND rm -Rf ${TARGETDIR}/${BLENDER_VERSION}
150                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/
151                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/${BLENDER_VERSION}/
152                 )
153         
154                 IF(WITH_INTERNATIONAL)
155                         ADD_CUSTOM_COMMAND(
156                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
157                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/${BLENDER_VERSION}/
158                                 COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/${BLENDER_VERSION}/
159                         )
160                 ENDIF(WITH_INTERNATIONAL)
161         
162                 IF(WITH_PYTHON)
163                         ADD_CUSTOM_COMMAND(
164                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
165                                 COMMENT "copying blender scripts..."
166                                 COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/${BLENDER_VERSION}/
167                                 COMMAND find ${TARGETDIR} -name "*.py?" -prune -exec rm -rf {} "\;"
168                         )
169                         IF(WITH_PYTHON_INSTALL)
170                                 # Copy the systems python into the install directory
171                                 # Scons copy in tools/Blender.py
172                                 ADD_CUSTOM_COMMAND(
173                                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
174                                         COMMENT "copying a subset of the systems python..."
175
176                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python # PYTHONPATH and PYTHONHOME is set here
177                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python/lib/
178                                         COMMAND cp -R ${PYTHON_LIBPATH}/python${PYTHON_VERSION} ${TARGETDIR}/${BLENDER_VERSION}/python/lib/
179
180                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/distutils
181                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/lib2to3
182                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/idlelib
183                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/tkinter
184                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/config
185
186                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/site-packages
187                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/site-packages  # python needs it.
188
189                                         COMMAND rm -f ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/lib-dynload/_tkinter.so
190                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "test" -prune -exec rm -rf {} "\;"
191                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "*.py?" -exec rm -rf {} "\;"
192                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "*.so"-exec strip -s {} "\;"
193                                 )
194                         ENDIF(WITH_PYTHON_INSTALL)
195                 ENDIF(WITH_PYTHON)
196           
197                 ADD_CUSTOM_COMMAND(
198                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
199                         COMMAND find ${TARGETDIR} -name .svn -prune -exec rm -rf {} "\;"
200                 )
201         
202         
203                 # Above we bundle a portable distribution in ./bin
204                 # This is an optional "make install" which installs blender on the system.
205                 INSTALL(
206                         PROGRAMS ${TARGETDIR}/blender
207                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
208                 )
209
210                 IF(WITH_GAMEENGINE AND WITH_PLAYER)
211                         INSTALL(
212                                 PROGRAMS ${TARGETDIR}/blenderplayer
213                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
214                         )
215                 ENDIF(WITH_GAMEENGINE AND WITH_PLAYER)
216
217                 INSTALL(
218                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
219                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
220                 )
221                 INSTALL(
222                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/blender.svg
223                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps
224                 )
225                 INSTALL(
226                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
227                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
228                 )
229                 INSTALL(
230                         FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
231                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
232                 )
233                 INSTALL(
234                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
235                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
236                         PATTERN ".svn" EXCLUDE
237                 )
238                 INSTALL(
239                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts/
240                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/scripts
241                         PATTERN ".svn" EXCLUDE
242                         PATTERN "*.pyc" EXCLUDE
243                 )
244                 INSTALL(
245                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/brushicons/
246                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/datafiles/brushicons
247                         PATTERN ".svn" EXCLUDE
248                 )
249                 IF(WITH_INTERNATIONAL)
250                         INSTALL(
251                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/
252                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/datafiles/locale
253                                 PATTERN ".svn" EXCLUDE
254                         )
255                 ENDIF(WITH_INTERNATIONAL)
256                 
257                 # end "make install"
258         
259         ELSEIF(WIN32)
260                 # notice 'xcopy /Y /H' on .bfont.ttf, this is needed when building over samba
261                 ADD_CUSTOM_COMMAND(TARGET blender
262                         POST_BUILD
263                         MAIN_DEPENDENCY blender
264                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\"
265                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\"
266                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\"
267                         COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
268                         COMMAND xcopy /Y /H \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\"
269                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\\\"
270                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\plugins\\\"
271                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\\\"
272                 )
273         
274                 IF(CMAKE_CL_64)
275                         # gettext and png are statically linked on win64
276                         ADD_CUSTOM_COMMAND(TARGET blender
277                                 POST_BUILD
278                                 MAIN_DEPENDENCY blender
279                                 COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
280                         )
281                 ELSE(CMAKE_CL_64)
282                         ADD_CUSTOM_COMMAND(TARGET blender
283                                 POST_BUILD
284                                 MAIN_DEPENDENCY blender
285                                 COMMAND copy /Y \"${LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\"
286                                 COMMAND copy /Y \"${LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\"
287                                 COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
288                         )
289                 ENDIF(CMAKE_CL_64)
290                 
291                 
292                 IF(MSVC)
293                         ADD_CUSTOM_COMMAND(TARGET blender
294                                 POST_BUILD
295                                 MAIN_DEPENDENCY blender
296                                 COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
297                         )
298                 ELSE(MSVC)
299                         ADD_CUSTOM_COMMAND(TARGET blender
300                                 POST_BUILD
301                                 MAIN_DEPENDENCY blender
302                                 COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadGC2.dll\" \"${TARGETDIR}\\\"
303                         )
304                 ENDIF(MSVC)
305
306                 IF(WITH_PYTHON)
307                         IF(NOT CMAKE_BUILD_TYPE) # hack: with multi-configuration generator this is "", so for now copy both python31.dll/zip and python31_d.dll/zip
308                                 ADD_CUSTOM_COMMAND(TARGET blender
309                                         POST_BUILD
310                                         MAIN_DEPENDENCY blender
311                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\"
312                                         COMMAND if \"$(ConfigurationName)\" == \"\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
313                                         COMMAND if \"$(ConfigurationName)\" == \"\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
314                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
315                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
316                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
317                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
318                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
319                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
320                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
321                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
322                                 )
323                         ELSE(NOT CMAKE_BUILD_TYPE)
324                                 IF(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
325                                         ADD_CUSTOM_COMMAND(TARGET blender
326                                                 POST_BUILD
327                                                 MAIN_DEPENDENCY blender
328                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
329                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
330                                         )
331                                 ELSE(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
332                                         ADD_CUSTOM_COMMAND(TARGET blender
333                                                 POST_BUILD
334                                                 MAIN_DEPENDENCY blender
335                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
336                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
337                                         )
338                                 ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
339                         ENDIF(NOT CMAKE_BUILD_TYPE)
340                 ENDIF(WITH_PYTHON)
341
342                 IF(WITH_INTERNATIONAL)
343                         IF(CMAKE_CL_64)
344                                 # iconv is statically linked on win64
345                                 ADD_CUSTOM_COMMAND(TARGET blender
346                                         POST_BUILD
347                                         MAIN_DEPENDENCY blender
348                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
349                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
350                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
351                                 )
352                         ELSE(CMAKE_CL_64)
353                                 ADD_CUSTOM_COMMAND(TARGET blender
354                                         POST_BUILD
355                                         MAIN_DEPENDENCY blender
356                                         COMMAND copy /Y \"${LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
357                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
358                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
359                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
360                                 )
361                         ENDIF(CMAKE_CL_64)
362                 ENDIF(WITH_INTERNATIONAL)
363
364                 IF(WITH_CODEC_FFMPEG)
365                         ADD_CUSTOM_COMMAND(TARGET blender
366                                 POST_BUILD
367                                 MAIN_DEPENDENCY blender
368                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
369                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
370                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
371                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
372                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
373                         )
374                 ENDIF(WITH_CODEC_FFMPEG)
375
376                 IF(WITH_CODEC_SNDFILE)
377                         ADD_CUSTOM_COMMAND(TARGET blender
378                                 POST_BUILD
379                                 MAIN_DEPENDENCY blender
380                                 COMMAND copy /Y \"${LIBDIR}\\sndfile\\lib\\libsndfile-1.dll\" \"${TARGETDIR}\\\"
381                         )
382                 ENDIF(WITH_CODEC_SNDFILE)
383
384                 IF(WITH_JACK)
385                         ADD_CUSTOM_COMMAND(TARGET blender
386                                 POST_BUILD
387                                 MAIN_DEPENDENCY blender
388                                 COMMAND copy /Y \"${LIBDIR}\\jack\\lib\\libjack.dll\" \"${TARGETDIR}\\\"
389                         )
390                 ENDIF(WITH_JACK)
391
392                 IF(WITH_OPENAL)
393                         ADD_CUSTOM_COMMAND(TARGET blender
394                                 POST_BUILD
395                                 MAIN_DEPENDENCY blender
396                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\OpenAL32.dll\" \"${TARGETDIR}\\\"
397                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\wrap_oal.dll\" \"${TARGETDIR}\\\"
398
399                         )
400                 ENDIF(WITH_OPENAL)
401
402                 IF(WITH_SDL)
403                         IF(NOT CMAKE_CL_64)
404                                 ADD_CUSTOM_COMMAND(TARGET blender
405                                         POST_BUILD
406                                         MAIN_DEPENDENCY blender
407                                         COMMAND copy /Y \"${LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
408                                 )
409                         ENDIF(NOT CMAKE_CL_64)
410                 ENDIF(WITH_SDL)
411
412         ELSEIF(APPLE)
413                 SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
414                 SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
415                 SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
416
417                 ADD_CUSTOM_COMMAND(
418                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
419                         COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
420                         COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
421                         COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
422                         COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
423                         COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
424                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
425                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
426                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
427                 )
428           
429                 IF(WITH_INTERNATIONAL)
430                         ADD_CUSTOM_COMMAND(
431                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
432                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
433                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
434                         )
435                 ENDIF(WITH_INTERNATIONAL)
436           
437                 IF(WITH_PYTHON)
438                         SET(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
439                         ADD_CUSTOM_COMMAND(
440                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
441                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/
442                                 COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
443                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
444                                 COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;"
445                         )
446                 ENDIF(WITH_PYTHON)        
447         
448                 ADD_CUSTOM_COMMAND(
449                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender       
450                         COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
451                         COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
452                                         COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;"
453                 )
454         ENDIF(UNIX AND NOT APPLE)
455
456 ENDIF(WITH_INSTALL)
457
458 ADD_DEPENDENCIES(blender makesdna)
459
460 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
461
462 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
463
464 IF(WITH_MOD_FLUID)
465         LIST(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
466 ENDIF(WITH_MOD_FLUID)
467
468
469 #IF(UNIX)
470         # Sort libraries
471         SET(BLENDER_SORTED_LIBS
472                 bf_windowmanager
473
474                 bf_editor_space_api
475                 bf_editor_space_action
476                 bf_editor_space_buttons
477                 bf_editor_space_console
478                 bf_editor_space_file
479                 bf_editor_space_graph
480                 bf_editor_space_image
481                 bf_editor_space_info
482                 bf_editor_space_logic
483                 bf_editor_space_nla
484                 bf_editor_space_node
485                 bf_editor_space_outliner
486                 bf_editor_space_script
487                 bf_editor_space_sequencer
488                 bf_editor_space_sound
489                 bf_editor_space_time
490                 bf_editor_space_userpref
491                 bf_editor_space_view3d
492
493                 bf_editor_text
494                 bf_editor_transform
495                 bf_editor_util
496                 bf_editor_uvedit
497                 bf_editor_curve
498                 bf_editor_armature
499                 bf_editor_gpencil
500                 bf_editor_interface
501                 bf_editor_mesh
502                 bf_editor_metaball
503                 bf_editor_object
504                 bf_editor_physics
505                 bf_editor_render
506                 bf_editor_screen
507                 bf_editor_sculpt_paint
508                 bf_editor_sound
509                 bf_editor_animation
510                 bf_editor_datafiles
511
512                 bf_render 
513                 bf_intern_opennl 
514                 bf_python 
515                 bf_python_ext 
516                 bf_ikplugin
517                 bf_modifiers
518                 bf_blenkernel
519                 bf_nodes
520                 bf_gpu
521                 bf_blenloader
522                 bf_blenlib
523                 bf_intern_ghost
524                 bf_intern_string
525                 bf_blenpluginapi 
526                 bf_imbuf 
527                 bf_avi 
528                 bf_imbuf_cineon 
529                 bf_imbuf_openexr 
530                 bf_imbuf_dds
531                 bf_readblenfile
532                 bf_collada
533                 bf_intern_bsp 
534                 bf_intern_bop 
535                 bf_gen_system 
536                 bf_intern_decimate 
537                 bf_intern_elbeem 
538                 bf_intern_ik 
539                 bf_intern_memutil 
540                 bf_intern_guardedalloc 
541                 bf_intern_ctr 
542                 ge_blen_routines 
543                 ge_converter 
544                 ge_phys_dummy
545                 ge_phys_bullet 
546                 bf_intern_smoke
547                 extern_minilzo
548                 extern_lzma
549                 ge_logic_ketsji 
550                 ge_phys_common
551                 ge_logic 
552                 ge_rasterizer 
553                 ge_oglrasterizer 
554                 ge_logic_expressions 
555                 ge_scenegraph 
556                 ge_logic_network 
557                 bf_gen_system
558                 bf_python # duplicate for BPY_eval_driver
559                 ge_logic_ngnetwork 
560                 extern_bullet 
561                 ge_logic_loopbacknetwork 
562                 bf_intern_moto 
563                 extern_glew
564                 extern_openjpeg
565                 extern_redcode
566                 ge_videotex
567                 bf_rna
568                 bf_dna
569                 bf_blenfont
570                 bf_intern_audaspace
571         )
572
573         IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
574                 LIST(APPEND BLENDER_SORTED_LIBS extern_binreloc)
575         ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
576
577         IF(WITH_CXX_GUARDEDALLOC)
578                 LIST(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
579         ENDIF(WITH_CXX_GUARDEDALLOC)
580
581         IF(WITH_IK_ITASC)
582                 LIST(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
583         ENDIF(WITH_IK_ITASC)
584
585         IF(WITH_CODEC_QUICKTIME)
586                 LIST(APPEND BLENDER_SORTED_LIBS bf_quicktime)
587         ENDIF(WITH_CODEC_QUICKTIME)
588
589
590         FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
591                 SET(REMLIB ${SORTLIB})
592                 FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
593                         IF(${SEARCHLIB} STREQUAL ${SORTLIB})
594                                 SET(REMLIB "")
595                         ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
596                 ENDFOREACH(SEARCHLIB)
597                 IF(REMLIB)
598                         MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
599                         LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
600                 ENDIF(REMLIB)
601         ENDFOREACH(SORTLIB)
602         TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
603 #ELSE(UNIX)
604 #       TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
605 #ENDIF(UNIX)
606
607 SETUP_LIBLINKS(blender)