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