synched with trunk at revision 34793
[blender-staging.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/windowmanager
44 )
45
46 if(WITH_CODEC_QUICKTIME)
47         add_definitions(-DWITH_QUICKTIME)
48 endif()
49
50 if(WITH_IMAGE_OPENEXR)
51         add_definitions(-DWITH_OPENEXR)
52 endif()
53
54 if(WITH_IMAGE_TIFF)
55         add_definitions(-DWITH_TIFF)
56 endif()
57
58 if(WITH_IMAGE_DDS)
59         add_definitions(-DWITH_DDS)
60 endif()
61
62 if(WITH_IMAGE_CINEON)
63         add_definitions(-DWITH_CINEON)
64 endif()
65
66 if(WITH_IMAGE_HDR)
67         add_definitions(-DWITH_HDR)
68 endif()
69
70 if(WITH_PYTHON)
71         blender_include_dirs(../blender/python)
72         add_definitions(-DWITH_PYTHON)
73 endif()
74
75 if(WITH_GAMEENGINE)
76         blender_include_dirs(
77                 ../kernel/gen_messaging
78                 ../kernel/gen_system
79         )
80
81         add_definitions(-DWITH_GAMEENGINE)
82 endif()
83
84 if(NOT WITH_SDL)
85         add_definitions(-DDISABLE_SDL)
86 endif()
87
88 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
89         add_definitions(-DWITH_BINRELOC)
90         blender_include_dirs(${BINRELOC_INC})
91 endif()
92
93 # Setup the exe sources and buildinfo
94 set(SRC
95         creator.c
96 )
97
98 if(WIN32 AND NOT UNIX)
99         list(APPEND SRC
100                 ../icons/winblender.rc
101         )
102 endif()
103
104 if(WITH_BUILDINFO)
105         string(REPLACE " " "\ " BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}")
106         string(REPLACE " " "\ " BUILDINFO_CXXFLAGS "${CMAKE_CXX_FLAGS}")
107         string(REPLACE " " "\ " BUILDINFO_LINKFLAGS "${PLATFORM_LINKFLAGS}")
108         add_definitions(
109                 -DBUILD_DATE="${BUILD_DATE}"
110                 -DBUILD_TIME="${BUILD_TIME}"
111                 -DBUILD_REV="${BUILD_REV}"
112                 -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
113                 -DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
114                 -DBUILD_CFLAGS="${BUILDINFO_CFLAGS}"
115                 -DBUILD_CXXFLAGS="${BUILDINFO_CXXFLAGS}"
116                 -DBUILD_LINKFLAGS="${BUILDINFO_LINKFLAGS}"
117                 -DBUILD_SYSTEM="CMake"
118         )
119
120         list(APPEND SRC
121                 buildinfo.c
122         )
123 endif()
124
125 # message(STATUS "Configuring blender")
126
127 add_executable(blender ${EXETYPE} ${SRC})
128
129 # Post build steps for bundling/packaging.
130
131 set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
132
133 if(WITH_INSTALL)
134
135         if(UNIX)
136                 add_custom_command(TARGET blender
137                         POST_BUILD
138                         MAIN_DEPENDENCY blender
139                         #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/
140                         #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
141                 )
142         endif()
143
144         if(UNIX AND NOT APPLE)
145                 
146                 # Local installation, "make install" can be done after this optionally
147                 
148                 add_custom_command(
149                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
150                         COMMAND rm -Rf ${TARGETDIR}/${BLENDER_VERSION}
151                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/
152                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/${BLENDER_VERSION}/
153                 )
154         
155                 if(WITH_INTERNATIONAL)
156                         add_custom_command(
157                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
158                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/${BLENDER_VERSION}/
159                                 COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/${BLENDER_VERSION}/
160                         )
161                 endif()
162         
163                 if(WITH_PYTHON)
164                         add_custom_command(
165                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
166                                 COMMENT "copying blender scripts..."
167                                 COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/${BLENDER_VERSION}/
168                                 COMMAND find ${TARGETDIR} -name "*.py?" -prune -exec rm -rf {} "\;"
169                         )
170                         if(WITH_PYTHON_INSTALL)
171                                 # Copy the systems python into the install directory
172                                 # Scons copy in tools/Blender.py
173                                 add_custom_command(
174                                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
175                                         COMMENT "copying a subset of the systems python..."
176
177                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python # PYTHONPATH and PYTHONHOME is set here
178                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python/lib/
179                                         COMMAND cp -R ${PYTHON_LIBPATH}/python${PYTHON_VERSION} ${TARGETDIR}/${BLENDER_VERSION}/python/lib/
180
181                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/distutils
182                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/lib2to3
183                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/idlelib
184                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/tkinter
185                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/config
186
187                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/site-packages
188                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/site-packages  # python needs it.
189
190                                         COMMAND rm -f ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/lib-dynload/_tkinter.so
191                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "test" -prune -exec rm -rf {} "\;"
192                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "*.py?" -exec rm -rf {} "\;"
193                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "*.so"-exec strip -s {} "\;"
194                                 )
195                         endif()
196                 endif()
197           
198                 add_custom_command(
199                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
200                         COMMAND find ${TARGETDIR} -name .svn -prune -exec rm -rf {} "\;"
201                 )
202         
203         
204                 # Above we bundle a portable distribution in ./bin
205                 # This is an optional "make install" which installs blender on the system.
206                 install(
207                         PROGRAMS ${TARGETDIR}/blender
208                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
209                 )
210
211                 if(WITH_GAMEENGINE AND WITH_PLAYER)
212                         install(
213                                 PROGRAMS ${TARGETDIR}/blenderplayer
214                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
215                         )
216                 endif()
217
218                 install(
219                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
220                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
221                 )
222                 install(
223                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/blender.svg
224                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps
225                 )
226                 install(
227                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
228                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
229                 )
230                 install(
231                         FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
232                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
233                 )
234                 install(
235                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
236                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
237                         PATTERN ".svn" EXCLUDE
238                 )
239                 install(
240                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts/
241                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/scripts
242                         PATTERN ".svn" EXCLUDE
243                         PATTERN "*.pyc" EXCLUDE
244                         PATTERN "__pycache__" 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                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
310                         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
311                                 add_custom_command(TARGET blender
312                                         POST_BUILD
313                                         MAIN_DEPENDENCY blender
314                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\"
315                                         COMMAND if \"$(ConfigurationName)\" == \"\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
316                                         COMMAND if \"$(ConfigurationName)\" == \"\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
317                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
318                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
319                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
320                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
321                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
322                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
323                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
324                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
325                                 )
326                         else()
327                                 if(CMAKE_BUILD_TYPE STREQUAL Debug)
328                                         add_custom_command(TARGET blender
329                                                 POST_BUILD
330                                                 MAIN_DEPENDENCY blender
331                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
332                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
333                                         )
334                                 else()
335                                         add_custom_command(TARGET blender
336                                                 POST_BUILD
337                                                 MAIN_DEPENDENCY blender
338                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
339                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
340                                         )
341                                 endif()
342                         endif()
343                 endif()
344
345                 if(WITH_INTERNATIONAL)
346                         if(CMAKE_CL_64)
347                                 # iconv is statically linked on win64
348                                 add_custom_command(TARGET blender
349                                         POST_BUILD
350                                         MAIN_DEPENDENCY blender
351                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
352                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
353                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
354                                 )
355                         else()
356                                 add_custom_command(TARGET blender
357                                         POST_BUILD
358                                         MAIN_DEPENDENCY blender
359                                         COMMAND copy /Y \"${LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
360                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
361                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
362                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
363                                 )
364                         endif()
365                 endif()
366
367                 if(WITH_CODEC_FFMPEG)
368                         add_custom_command(TARGET blender
369                                 POST_BUILD
370                                 MAIN_DEPENDENCY blender
371                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
372                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
373                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
374                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
375                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
376                         )
377                 endif()
378
379                 if(WITH_CODEC_SNDFILE)
380                         add_custom_command(TARGET blender
381                                 POST_BUILD
382                                 MAIN_DEPENDENCY blender
383                                 COMMAND copy /Y \"${LIBDIR}\\sndfile\\lib\\libsndfile-1.dll\" \"${TARGETDIR}\\\"
384                         )
385                 endif()
386
387                 if(WITH_JACK)
388                         add_custom_command(TARGET blender
389                                 POST_BUILD
390                                 MAIN_DEPENDENCY blender
391                                 COMMAND copy /Y \"${LIBDIR}\\jack\\lib\\libjack.dll\" \"${TARGETDIR}\\\"
392                         )
393                 endif()
394
395                 if(WITH_OPENAL)
396                         add_custom_command(TARGET blender
397                                 POST_BUILD
398                                 MAIN_DEPENDENCY blender
399                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\OpenAL32.dll\" \"${TARGETDIR}\\\"
400                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\wrap_oal.dll\" \"${TARGETDIR}\\\"
401
402                         )
403                 endif()
404
405                 if(WITH_SDL)
406                         if(NOT CMAKE_CL_64)
407                                 add_custom_command(TARGET blender
408                                         POST_BUILD
409                                         MAIN_DEPENDENCY blender
410                                         COMMAND copy /Y \"${LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
411                                 )
412                         endif()
413                 endif()
414
415         elseif(APPLE)
416                 set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
417                 set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
418                 set(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
419
420                 add_custom_command(
421                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
422                         COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
423                         COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
424                         COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
425                         COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
426                         COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
427                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
428                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
429                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
430                 )
431           
432                 if(WITH_INTERNATIONAL)
433                         add_custom_command(
434                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
435                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
436                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
437                         )
438                 endif()
439           
440                 if(WITH_PYTHON)
441                         set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
442                         add_custom_command(
443                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
444                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/
445                                 COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
446                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
447                                 COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;"
448                         )
449                 endif()   
450         
451                 add_custom_command(
452                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender       
453                         COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
454                         COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
455                                         COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;"
456                 )
457         endif()
458
459 endif()
460
461 add_dependencies(blender makesdna)
462
463 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
464
465 set(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
466
467 if(WITH_MOD_FLUID)
468         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
469 endif()
470
471
472 #if(UNIX)
473         # Sort libraries
474         set(BLENDER_SORTED_LIBS
475                 bf_windowmanager
476
477                 bf_editor_space_api
478                 bf_editor_space_action
479                 bf_editor_space_buttons
480                 bf_editor_space_console
481                 bf_editor_space_file
482                 bf_editor_space_graph
483                 bf_editor_space_image
484                 bf_editor_space_info
485                 bf_editor_space_logic
486                 bf_editor_space_nla
487                 bf_editor_space_node
488                 bf_editor_space_outliner
489                 bf_editor_space_script
490                 bf_editor_space_sequencer
491                 bf_editor_space_sound
492                 bf_editor_space_time
493                 bf_editor_space_userpref
494                 bf_editor_space_view3d
495
496                 bf_editor_text
497                 bf_editor_transform
498                 bf_editor_util
499                 bf_editor_uvedit
500                 bf_editor_curve
501                 bf_editor_armature
502                 bf_editor_gpencil
503                 bf_editor_interface
504                 bf_editor_mesh
505                 bf_editor_metaball
506                 bf_editor_object
507                 bf_editor_physics
508                 bf_editor_render
509                 bf_editor_screen
510                 bf_editor_sculpt_paint
511                 bf_editor_sound
512                 bf_editor_animation
513                 bf_editor_datafiles
514
515                 bf_render 
516                 bf_intern_opennl 
517                 bf_python 
518                 bf_python_ext 
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                 extern_recastnavigation
575         )
576
577         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
578                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
579         endif()
580
581         if(WITH_CXX_GUARDEDALLOC)
582                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
583         endif()
584
585         if(WITH_IK_ITASC)
586                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
587         endif()
588
589         if(WITH_CODEC_QUICKTIME)
590                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
591         endif()
592
593         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
594                 set(REMLIB ${SORTLIB})
595                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
596                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
597                                 set(REMLIB "")
598                         endif()
599                 endforeach()
600                 if(REMLIB)
601                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
602                         list(APPEND REM_MSG ${REMLIB})
603                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
604                 endif()
605         endforeach()
606         if(REM_MSG)
607                 list(SORT REM_MSG)
608                 message(STATUS "Blender Skipping: (${REM_MSG})")
609         endif()
610         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
611 #else()
612 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
613 #endif()
614
615 setup_liblinks(blender)