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