Compact -I paths in makefiles for more readble files/output.
[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                         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
309                                 add_custom_command(TARGET blender
310                                         POST_BUILD
311                                         MAIN_DEPENDENCY blender
312                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\"
313                                         COMMAND if \"$(ConfigurationName)\" == \"\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
314                                         COMMAND if \"$(ConfigurationName)\" == \"\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
315                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
316                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
317                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
318                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
319                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
320                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
321                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
322                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
323                                 )
324                         else()
325                                 if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
326                                         add_custom_command(TARGET blender
327                                                 POST_BUILD
328                                                 MAIN_DEPENDENCY blender
329                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
330                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
331                                         )
332                                 else()
333                                         add_custom_command(TARGET blender
334                                                 POST_BUILD
335                                                 MAIN_DEPENDENCY blender
336                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
337                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
338                                         )
339                                 endif()
340                         endif()
341                 endif()
342
343                 if(WITH_INTERNATIONAL)
344                         if(CMAKE_CL_64)
345                                 # iconv is statically linked on win64
346                                 add_custom_command(TARGET blender
347                                         POST_BUILD
348                                         MAIN_DEPENDENCY blender
349                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
350                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
351                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
352                                 )
353                         else()
354                                 add_custom_command(TARGET blender
355                                         POST_BUILD
356                                         MAIN_DEPENDENCY blender
357                                         COMMAND copy /Y \"${LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
358                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
359                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
360                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
361                                 )
362                         endif()
363                 endif()
364
365                 if(WITH_CODEC_FFMPEG)
366                         add_custom_command(TARGET blender
367                                 POST_BUILD
368                                 MAIN_DEPENDENCY blender
369                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
370                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
371                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
372                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
373                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
374                         )
375                 endif()
376
377                 if(WITH_CODEC_SNDFILE)
378                         add_custom_command(TARGET blender
379                                 POST_BUILD
380                                 MAIN_DEPENDENCY blender
381                                 COMMAND copy /Y \"${LIBDIR}\\sndfile\\lib\\libsndfile-1.dll\" \"${TARGETDIR}\\\"
382                         )
383                 endif()
384
385                 if(WITH_JACK)
386                         add_custom_command(TARGET blender
387                                 POST_BUILD
388                                 MAIN_DEPENDENCY blender
389                                 COMMAND copy /Y \"${LIBDIR}\\jack\\lib\\libjack.dll\" \"${TARGETDIR}\\\"
390                         )
391                 endif()
392
393                 if(WITH_OPENAL)
394                         add_custom_command(TARGET blender
395                                 POST_BUILD
396                                 MAIN_DEPENDENCY blender
397                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\OpenAL32.dll\" \"${TARGETDIR}\\\"
398                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\wrap_oal.dll\" \"${TARGETDIR}\\\"
399
400                         )
401                 endif()
402
403                 if(WITH_SDL)
404                         if(NOT CMAKE_CL_64)
405                                 add_custom_command(TARGET blender
406                                         POST_BUILD
407                                         MAIN_DEPENDENCY blender
408                                         COMMAND copy /Y \"${LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
409                                 )
410                         endif()
411                 endif()
412
413         elseif(APPLE)
414                 set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
415                 set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
416                 set(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
417
418                 add_custom_command(
419                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
420                         COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
421                         COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
422                         COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
423                         COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
424                         COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
425                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
426                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
427                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
428                 )
429           
430                 if(WITH_INTERNATIONAL)
431                         add_custom_command(
432                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
433                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
434                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
435                         )
436                 endif()
437           
438                 if(WITH_PYTHON)
439                         set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
440                         add_custom_command(
441                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
442                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/
443                                 COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
444                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
445                                 COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;"
446                         )
447                 endif()   
448         
449                 add_custom_command(
450                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender       
451                         COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
452                         COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
453                                         COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;"
454                 )
455         endif()
456
457 endif()
458
459 add_dependencies(blender makesdna)
460
461 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
462
463 set(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
464
465 if(WITH_MOD_FLUID)
466         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
467 endif()
468
469
470 #if(UNIX)
471         # Sort libraries
472         set(BLENDER_SORTED_LIBS
473                 bf_windowmanager
474
475                 bf_editor_space_api
476                 bf_editor_space_action
477                 bf_editor_space_buttons
478                 bf_editor_space_console
479                 bf_editor_space_file
480                 bf_editor_space_graph
481                 bf_editor_space_image
482                 bf_editor_space_info
483                 bf_editor_space_logic
484                 bf_editor_space_nla
485                 bf_editor_space_node
486                 bf_editor_space_outliner
487                 bf_editor_space_script
488                 bf_editor_space_sequencer
489                 bf_editor_space_sound
490                 bf_editor_space_time
491                 bf_editor_space_userpref
492                 bf_editor_space_view3d
493
494                 bf_editor_text
495                 bf_editor_transform
496                 bf_editor_util
497                 bf_editor_uvedit
498                 bf_editor_curve
499                 bf_editor_armature
500                 bf_editor_gpencil
501                 bf_editor_interface
502                 bf_editor_mesh
503                 bf_editor_metaball
504                 bf_editor_object
505                 bf_editor_physics
506                 bf_editor_render
507                 bf_editor_screen
508                 bf_editor_sculpt_paint
509                 bf_editor_sound
510                 bf_editor_animation
511                 bf_editor_datafiles
512
513                 bf_render 
514                 bf_intern_opennl 
515                 bf_python 
516                 bf_python_ext 
517                 bf_ikplugin
518                 bf_modifiers
519                 bf_blenkernel
520                 bf_nodes
521                 bf_gpu
522                 bf_blenloader
523                 bf_blenlib
524                 bf_intern_ghost
525                 bf_intern_string
526                 bf_blenpluginapi 
527                 bf_imbuf 
528                 bf_avi 
529                 bf_imbuf_cineon 
530                 bf_imbuf_openexr 
531                 bf_imbuf_dds
532                 bf_readblenfile
533                 bf_collada
534                 bf_intern_bsp 
535                 bf_intern_bop 
536                 bf_gen_system 
537                 bf_intern_decimate 
538                 bf_intern_elbeem 
539                 bf_intern_ik 
540                 bf_intern_memutil 
541                 bf_intern_guardedalloc 
542                 bf_intern_ctr 
543                 ge_blen_routines 
544                 ge_converter 
545                 ge_phys_dummy
546                 ge_phys_bullet 
547                 bf_intern_smoke
548                 extern_minilzo
549                 extern_lzma
550                 ge_logic_ketsji 
551                 ge_phys_common
552                 ge_logic 
553                 ge_rasterizer 
554                 ge_oglrasterizer 
555                 ge_logic_expressions 
556                 ge_scenegraph 
557                 ge_logic_network 
558                 bf_gen_system
559                 bf_python # duplicate for BPY_eval_driver
560                 ge_logic_ngnetwork 
561                 extern_bullet 
562                 ge_logic_loopbacknetwork 
563                 bf_intern_moto 
564                 extern_glew
565                 extern_openjpeg
566                 extern_redcode
567                 ge_videotex
568                 bf_rna
569                 bf_dna
570                 bf_blenfont
571                 bf_intern_audaspace
572         )
573
574         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
575                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
576         endif()
577
578         if(WITH_CXX_GUARDEDALLOC)
579                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
580         endif()
581
582         if(WITH_IK_ITASC)
583                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
584         endif()
585
586         if(WITH_CODEC_QUICKTIME)
587                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
588         endif()
589
590         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
591                 set(REMLIB ${SORTLIB})
592                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
593                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
594                                 set(REMLIB "")
595                         endif()
596                 endforeach()
597                 if(REMLIB)
598                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
599                         list(APPEND REM_MSG ${REMLIB})
600                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
601                 endif()
602         endforeach()
603         if(REM_MSG)
604                 list(SORT REM_MSG)
605                 message(STATUS "Blender Skipping: (${REM_MSG})")
606         endif()
607         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
608 #else()
609 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
610 #endif()
611
612 setup_liblinks(blender)