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