- fix problem with cmake, windows 'RelWithDebInfo' target, was giving error: "ImportE...
[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/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                 )
245                 install(
246                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/brushicons/
247                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/datafiles/brushicons
248                         PATTERN ".svn" EXCLUDE
249                 )
250                 if(WITH_INTERNATIONAL)
251                         install(
252                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/
253                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/datafiles/locale
254                                 PATTERN ".svn" EXCLUDE
255                         )
256                 endif()
257                 
258                 # end "make install"
259         
260         elseif(WIN32)
261                 # notice 'xcopy /Y /H' on .bfont.ttf, this is needed when building over samba
262                 add_custom_command(TARGET blender
263                         POST_BUILD
264                         MAIN_DEPENDENCY blender
265                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\"
266                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\"
267                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\"
268                         COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
269                         COMMAND xcopy /Y /H \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\"
270                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\\\"
271                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\plugins\\\"
272                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\\\"
273                 )
274         
275                 if(CMAKE_CL_64)
276                         # gettext and png are statically linked on win64
277                         add_custom_command(TARGET blender
278                                 POST_BUILD
279                                 MAIN_DEPENDENCY blender
280                                 COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
281                         )
282                 else()
283                         add_custom_command(TARGET blender
284                                 POST_BUILD
285                                 MAIN_DEPENDENCY blender
286                                 COMMAND copy /Y \"${LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\"
287                                 COMMAND copy /Y \"${LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\"
288                                 COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
289                         )
290                 endif()
291                 
292                 
293                 if(MSVC)
294                         add_custom_command(TARGET blender
295                                 POST_BUILD
296                                 MAIN_DEPENDENCY blender
297                                 COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
298                         )
299                 else()
300                         add_custom_command(TARGET blender
301                                 POST_BUILD
302                                 MAIN_DEPENDENCY blender
303                                 COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadGC2.dll\" \"${TARGETDIR}\\\"
304                         )
305                 endif()
306
307                 if(WITH_PYTHON)
308                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
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)
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_ikplugin
519                 bf_modifiers
520                 bf_blenkernel
521                 bf_nodes
522                 bf_gpu
523                 bf_blenloader
524                 bf_blenlib
525                 bf_intern_ghost
526                 bf_intern_string
527                 bf_blenpluginapi 
528                 bf_imbuf 
529                 bf_avi 
530                 bf_imbuf_cineon 
531                 bf_imbuf_openexr 
532                 bf_imbuf_dds
533                 bf_readblenfile
534                 bf_collada
535                 bf_intern_bsp 
536                 bf_intern_bop 
537                 bf_gen_system 
538                 bf_intern_decimate 
539                 bf_intern_elbeem 
540                 bf_intern_ik 
541                 bf_intern_memutil 
542                 bf_intern_guardedalloc 
543                 bf_intern_ctr 
544                 ge_blen_routines 
545                 ge_converter 
546                 ge_phys_dummy
547                 ge_phys_bullet 
548                 bf_intern_smoke
549                 extern_minilzo
550                 extern_lzma
551                 ge_logic_ketsji 
552                 ge_phys_common
553                 ge_logic 
554                 ge_rasterizer 
555                 ge_oglrasterizer 
556                 ge_logic_expressions 
557                 ge_scenegraph 
558                 ge_logic_network 
559                 bf_gen_system
560                 bf_python # duplicate for BPY_driver_exec
561                 ge_logic_ngnetwork 
562                 extern_bullet 
563                 ge_logic_loopbacknetwork 
564                 bf_intern_moto 
565                 extern_glew
566                 extern_openjpeg
567                 extern_redcode
568                 ge_videotex
569                 bf_rna
570                 bf_dna
571                 bf_blenfont
572                 bf_intern_audaspace
573         )
574
575         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
576                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
577         endif()
578
579         if(WITH_CXX_GUARDEDALLOC)
580                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
581         endif()
582
583         if(WITH_IK_ITASC)
584                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
585         endif()
586
587         if(WITH_CODEC_QUICKTIME)
588                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
589         endif()
590
591         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
592                 set(REMLIB ${SORTLIB})
593                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
594                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
595                                 set(REMLIB "")
596                         endif()
597                 endforeach()
598                 if(REMLIB)
599                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
600                         list(APPEND REM_MSG ${REMLIB})
601                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
602                 endif()
603         endforeach()
604         if(REM_MSG)
605                 list(SORT REM_MSG)
606                 message(STATUS "Blender Skipping: (${REM_MSG})")
607         endif()
608         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
609 #else()
610 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
611 #endif()
612
613 setup_liblinks(blender)