436d2f4174992debddf2f88bee375453050f4c3b
[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         # --------------------------------------------------------------------------
111         # These defines could all be moved into the header below
112         string(REPLACE " " "\ " BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}")
113         string(REPLACE " " "\ " BUILDINFO_CXXFLAGS "${CMAKE_CXX_FLAGS}")
114         string(REPLACE " " "\ " BUILDINFO_LINKFLAGS "${PLATFORM_LINKFLAGS}")
115         add_definitions(
116                 # # define in header now, else these get out of date on rebuilds.
117                 # -DBUILD_DATE="${BUILD_DATE}"
118                 # -DBUILD_TIME="${BUILD_TIME}"
119                 # -DBUILD_REV="${BUILD_REV}"
120                 -DWITH_BUILDINFO_HEADER # alternative to lines above
121                 -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
122                 -DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
123                 -DBUILD_CFLAGS="${BUILDINFO_CFLAGS}"
124                 -DBUILD_CXXFLAGS="${BUILDINFO_CXXFLAGS}"
125                 -DBUILD_LINKFLAGS="${BUILDINFO_LINKFLAGS}"
126                 -DBUILD_SYSTEM="CMake"
127         )
128
129         # --------------------------------------------------------------------------
130         # write header for values that change each build
131         # note, generaed file is in build dir's source/creator
132         #       except when used as an include path.
133
134         # include the output directory, where the buildinfo.h file is generated
135         include_directories(${CMAKE_BINARY_DIR}/source/creator)
136
137         # a custom target that is always built
138         add_custom_target(buildinfo ALL
139                 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h)
140
141         # creates svnheader.h using cmake script
142         add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h
143                 COMMAND ${CMAKE_COMMAND}
144                 -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
145                 -P ${CMAKE_SOURCE_DIR}/build_files/cmake/buildinfo.cmake)
146
147         # buildinfo.h is a generated file
148         set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h
149                 PROPERTIES GENERATED TRUE
150                 HEADER_FILE_ONLY TRUE)
151
152         # add deps below, after adding blender
153         # -------------- done with header values.
154
155         list(APPEND SRC
156                 buildinfo.c
157         )
158 endif()
159
160 # message(STATUS "Configuring blender")
161 if(WITH_PYTHON_MODULE)
162         add_definitions(-DWITH_PYTHON_MODULE)
163
164         # creates ./bin/bpy.so which can be imported as a python module.
165         add_library(blender SHARED ${SRC})
166         set_target_properties(
167                 blender
168                 PROPERTIES
169                          PREFIX ""
170                          OUTPUT_NAME bpy
171                          LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/
172         )
173 else()
174         add_executable(blender ${EXETYPE} ${SRC})
175 endif()
176
177 if(WITH_BUILDINFO)
178         # explicitly say that the executable depends on the buildinfo
179         add_dependencies(blender buildinfo)
180 endif()
181
182 # Post build steps for bundling/packaging.
183
184
185 if(MSVC)
186         # ${CMAKE_CFG_INTDIR} should replace \${BUILD_TYPE} when using add_command
187         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE})
188 elseif(APPLE)
189         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
190 else()
191         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH})
192 endif()
193
194 if(WITH_INSTALL)
195
196         if(UNIX AND NOT APPLE)
197
198                 if(WITH_INSTALL_PORTABLE)
199                         set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
200                 else()
201                         set(TARGETDIR_VER ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION})
202                 endif()
203
204                 # important to make a clean  install each time
205                 # else old scripts get loaded.
206                 install(
207                         CODE
208                         "file(REMOVE_RECURSE ${TARGETDIR_VER})"
209                 )
210
211                 # message after building.
212                 add_custom_command(
213                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
214                         COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${TARGETDIR_VER}'
215                 )
216
217                 # there are a few differences between portable and system install
218                 if(WITH_INSTALL_PORTABLE)
219                         install(
220                                 FILES
221                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
222                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/blender.svg
223                                 ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
224                                 DESTINATION ${TARGETDIR}
225                         )
226
227                         install(
228                                 PROGRAMS
229                                 ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
230                                 DESTINATION ${TARGETDIR}
231                         )
232
233                         install(
234                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
235                                 DESTINATION ${TARGETDIR}
236                                 PATTERN ".svn" EXCLUDE
237                         )
238
239                 else()
240                         # main blender binary
241                         install(
242                                 PROGRAMS ${TARGETDIR}/blender
243                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
244                         )
245
246                         if(WITH_GAMEENGINE AND WITH_PLAYER)
247                                 install(
248                                         PROGRAMS ${TARGETDIR}/blenderplayer
249                                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
250                                 )
251                         endif()
252
253                         # misc files
254                         install(
255                                 FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
256                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
257                         )
258                         install(
259                                 FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/blender.svg
260                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps
261                         )
262                         install(
263                                 PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
264                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
265                         )
266                         install(
267                                 FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
268                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
269                         )
270                         install(
271                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
272                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
273                                 PATTERN ".svn" EXCLUDE
274                         )
275                 endif()
276
277                 install(
278                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
279                         DESTINATION ${TARGETDIR_VER}/config
280                 )
281
282                 if(WITH_INTERNATIONAL)
283                         install(
284                                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
285                                 DESTINATION ${TARGETDIR_VER}/config
286                         )
287
288                         install(
289                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
290                                 DESTINATION ${TARGETDIR_VER}/datafiles/
291                                 PATTERN ".svn" EXCLUDE
292                         )
293                 endif()
294
295                         # plugins in blender 2.5 don't work at the moment.
296                         #
297                         # install(
298                         #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
299                         #       DESTINATION ${TARGETDIR_VER}/
300                         #       PATTERN ".svn" EXCLUDE
301                         # )
302
303                 if(WITH_PYTHON)
304                         # install(CODE "message(\"copying blender scripts...\")")
305                         install(
306                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
307                                 DESTINATION ${TARGETDIR_VER}/
308                                 PATTERN ".svn" EXCLUDE
309                                 PATTERN "__pycache__" EXCLUDE
310                         )
311
312                         if(WITH_PYTHON_INSTALL)
313                                 # Copy the systems python into the install directory
314                                 # Scons copy in tools/Blender.py
315                                 # install(CODE "message(\"copying a subset of the systems python...\")")
316                                 install(
317                                         DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
318                                         DESTINATION ${TARGETDIR_VER}/python/lib/
319                                         PATTERN ".svn" EXCLUDE
320                                         PATTERN "__pycache__" EXCLUDE               # ./distutils
321                                         PATTERN "distutils" EXCLUDE                 # ./distutils
322                                         PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
323                                         PATTERN "config" EXCLUDE                    # ./config
324                                         PATTERN "config-*" EXCLUDE                  # ./config-*
325                                         PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
326                                         PATTERN "tkinter" EXCLUDE                   # ./tkinter
327                                         PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
328                                         PATTERN "test" EXCLUDE                      # ./test
329                                         PATTERN "turtledemo" EXCLUDE                # ./turtledemo
330                                 )
331
332                                 # # doesnt work, todo
333                                 # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
334                         endif()
335                 endif()
336         elseif(WIN32)
337
338                 set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
339
340                 install(  # same as linux!, deduplicate
341                         CODE
342                         "file(REMOVE_RECURSE ${TARGETDIR_VER})"
343                 )
344
345                 install(  # same as linux!, deduplicate
346                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
347                         DESTINATION ${TARGETDIR}/
348                         PATTERN ".svn" EXCLUDE
349                 )
350
351                 install(  # same as linux!, deduplicate
352                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
353                         DESTINATION ${TARGETDIR_VER}/config
354                 )
355
356                 if(WITH_INTERNATIONAL) # same as linux!, deduplicate
357                         install(
358                                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
359                                 DESTINATION ${TARGETDIR_VER}/config
360                         )
361                         install(
362                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
363                                 DESTINATION ${TARGETDIR_VER}/datafiles/
364                                 PATTERN ".svn" EXCLUDE
365                         )
366
367                         if(NOT CMAKE_CL_64)
368                                 install(
369                                         FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
370                                         DESTINATION ${TARGETDIR}/
371                                 )
372
373                                 install(
374                                         FILES ${LIBDIR}/iconv/lib/iconv.dll
375                                         DESTINATION ${TARGETDIR}/
376                                 )
377                         endif()
378                 endif()
379
380                 install( # same as linux!, deduplicate
381                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/
382                         DESTINATION ${TARGETDIR_VER}/datafiles/locale
383                         PATTERN ".svn" EXCLUDE
384                 )
385
386                 # plugins in blender 2.5 don't work at the moment.
387                 #
388                 # install(
389                 #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
390                 #       DESTINATION ${TARGETDIR_VER}/
391                 #       PATTERN ".svn" EXCLUDE
392                 # )
393
394                 if(WITH_PYTHON)
395                         # install(CODE "message(\"copying blender scripts...\")")
396                         install(  # same as linux!, deduplicate
397                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
398                                 DESTINATION ${TARGETDIR_VER}/
399                                 PATTERN ".svn" EXCLUDE
400                                 PATTERN "__pycache__" EXCLUDE
401                         )
402
403                         # TODO, multiple targets?
404                         install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS Release)
405                         install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS RelWithDebInfo)
406                         install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS MinSizeRel)
407
408                         install(
409                                 FILES ${LIBDIR}/python/lib/python32_d.dll
410                                 DESTINATION ${TARGETDIR}/
411                                 CONFIGURATIONS Debug
412                         )
413
414                         if(WITH_PYTHON_INSTALL)
415                                 #~ # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
416
417                                 # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
418                                 install(CODE "
419                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
420                                 file(MAKE_DIRECTORY ${TARGETDIR_VER}/python/)
421                                 file(MAKE_DIRECTORY ${TARGETDIR_VER}/python/lib/)
422                                 message(\"done creating dir\")
423                                 ")
424
425                                 install(
426                                         CODE
427                                         "
428                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
429                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
430                                         "
431                                         CONFIGURATIONS Release
432                                 )
433                                 install(
434                                         CODE
435                                         "
436                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
437                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
438                                         "
439                                         CONFIGURATIONS RelWithDebInfo
440                                 )
441                                 install(
442                                         CODE
443                                         "
444                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
445                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
446                                         "
447                                         CONFIGURATIONS MinSizeRel
448                                 )
449                                 install(
450                                         CODE
451                                         "
452                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
453                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32_d.tar.gz\")
454                                         "
455                                         CONFIGURATIONS Debug
456                                 )
457
458                                 # doesnt work, todo
459                                 # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
460                         endif()
461                 endif()
462
463                 if(CMAKE_CL_64)
464                         # gettext and png are statically linked on win64
465                         install(
466                                 FILES ${LIBDIR}/zlib/lib/zlib.dll
467                                 DESTINATION ${TARGETDIR}/
468                         )
469                 else()
470                         install(
471                                 FILES
472                                 ${LIBDIR}/png/lib/libpng.dll
473                                 ${LIBDIR}/zlib/lib/zlib.dll
474                                 DESTINATION ${TARGETDIR}/
475                         )
476                 endif()
477
478                 if(MSVC)
479                         install(
480                                 FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
481                                 DESTINATION ${TARGETDIR}/
482                         )
483                 else()
484                         install(
485                                 FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
486                                 DESTINATION ${TARGETDIR}/
487                         )
488                 endif()
489
490                 if(WITH_CODEC_FFMPEG)
491                         install(
492                                 FILES
493                                 ${LIBDIR}/ffmpeg/lib/avcodec-52.dll
494                                 ${LIBDIR}/ffmpeg/lib/avformat-52.dll
495                                 ${LIBDIR}/ffmpeg/lib/avdevice-52.dll
496                                 ${LIBDIR}/ffmpeg/lib/avutil-50.dll
497                                 ${LIBDIR}/ffmpeg/lib/swscale-0.dll
498                                 DESTINATION ${TARGETDIR}/
499                         )
500
501                 endif()
502
503                 if(WITH_CODEC_SNDFILE)
504                         install(
505                                 FILES
506                                 ${LIBDIR}/sndfile/lib/libsndfile-1.dll
507                                 DESTINATION ${TARGETDIR}/
508                         )
509                 endif()
510
511                 if(WITH_OPENAL)
512                         install(
513                                 FILES
514                                 ${LIBDIR}/openal/lib/OpenAL32.dll
515                                 ${LIBDIR}/openal/lib/wrap_oal.dll
516                                 DESTINATION ${TARGETDIR}/
517                         )
518                 endif()
519
520                 if(WITH_SDL)
521                         if(NOT CMAKE_CL_64)
522                                 install(
523                                         FILES
524                                         ${LIBDIR}/sdl/lib/SDL.dll
525                                         DESTINATION ${TARGETDIR}/
526                                 )
527                         endif()
528                 endif()
529
530         elseif(APPLE)
531                 # TODO, APPLE needs a 'make install' target like win32 and unix
532
533                 set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
534                 set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
535                 set(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
536
537                 add_custom_command(
538                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
539                         COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
540                 )
541
542                 add_custom_command(
543                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
544                         COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
545                         COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
546                         COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
547                         COMMAND cat ${SOURCEINFO} | sed s/VERSION/${BLENDER_VERSION}${BLENDER_VERSION_CHAR}/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
548                         COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
549                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
550                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
551                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
552                 )
553
554                 if(WITH_INTERNATIONAL)
555                         add_custom_command(
556                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
557                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
558                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
559                         )
560                 endif()
561
562                 if(WITH_PYTHON)
563                         set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
564                         add_custom_command(
565                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
566                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/
567                                 COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
568                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
569                                 COMMAND find ${TARGETDIR}/blender.app -name '*.py[co]' -prune -exec rm -rf {} '\;'
570                                 COMMAND find ${TARGETDIR}/blender.app -name '__pycache__' -exec rmdir {} '+'
571                         )
572                 endif()
573
574                 add_custom_command(
575                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
576                         COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
577                         COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
578                         COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;"
579                 )
580         endif()
581
582 endif()
583
584 add_dependencies(blender makesdna)
585
586 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
587
588 set(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
589
590 if(WITH_MOD_FLUID)
591         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
592 endif()
593
594
595 #if(UNIX)
596         # Sort libraries
597         set(BLENDER_SORTED_LIBS
598                 bf_windowmanager
599
600                 bf_editor_space_api
601                 bf_editor_space_action
602                 bf_editor_space_buttons
603                 bf_editor_space_console
604                 bf_editor_space_file
605                 bf_editor_space_graph
606                 bf_editor_space_image
607                 bf_editor_space_info
608                 bf_editor_space_logic
609                 bf_editor_space_nla
610                 bf_editor_space_node
611                 bf_editor_space_outliner
612                 bf_editor_space_script
613                 bf_editor_space_sequencer
614                 bf_editor_space_sound
615                 bf_editor_space_time
616                 bf_editor_space_userpref
617                 bf_editor_space_view3d
618
619                 bf_editor_text
620                 bf_editor_transform
621                 bf_editor_util
622                 bf_editor_uvedit
623                 bf_editor_curve
624                 bf_editor_armature
625                 bf_editor_gpencil
626                 bf_editor_interface
627                 bf_editor_mesh
628                 bf_editor_metaball
629                 bf_editor_object
630                 bf_editor_physics
631                 bf_editor_render
632                 bf_editor_screen
633                 bf_editor_sculpt_paint
634                 bf_editor_sound
635                 bf_editor_animation
636                 bf_editor_datafiles
637
638                 bf_render
639                 bf_intern_opennl
640                 bf_python
641                 bf_python_ext
642                 bf_ikplugin
643                 bf_modifiers
644                 bf_blenkernel
645                 bf_nodes
646                 bf_gpu
647                 bf_blenloader
648                 bf_blenlib
649                 bf_intern_ghost
650                 bf_intern_string
651                 bf_blenpluginapi
652                 bf_imbuf
653                 bf_avi
654                 bf_imbuf_cineon
655                 bf_imbuf_openexr
656                 bf_imbuf_dds
657                 bf_readblenfile
658                 bf_collada
659                 bf_intern_bsp
660                 bf_intern_bop
661                 bf_gen_system
662                 bf_intern_decimate
663                 bf_intern_elbeem
664                 bf_intern_ik
665                 bf_intern_memutil
666                 bf_intern_guardedalloc
667                 bf_intern_ctr
668                 ge_blen_routines
669                 ge_converter
670                 ge_phys_dummy
671                 ge_phys_bullet
672                 bf_intern_smoke
673                 extern_minilzo
674                 extern_lzma
675                 ge_logic_ketsji
676                 ge_phys_common
677                 ge_logic
678                 ge_rasterizer
679                 ge_oglrasterizer
680                 ge_logic_expressions
681                 ge_scenegraph
682                 ge_logic_network
683                 bf_gen_system
684                 bf_python # duplicate for BPY_driver_exec
685                 ge_logic_ngnetwork
686                 extern_bullet
687                 ge_logic_loopbacknetwork
688                 bf_intern_moto
689                 extern_glew
690                 extern_openjpeg
691                 extern_redcode
692                 ge_videotex
693                 bf_rna
694                 bf_dna
695                 bf_blenfont
696                 bf_intern_audaspace
697                 bf_intern_mikktspace
698         )
699
700         if(WITH_BINRELOC)
701                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
702         endif()
703
704         if(WITH_CXX_GUARDEDALLOC)
705                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
706         endif()
707
708         if(WITH_IK_ITASC)
709                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
710         endif()
711
712         if(WITH_CODEC_QUICKTIME)
713                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
714         endif()
715
716         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
717                 set(REMLIB ${SORTLIB})
718                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
719                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
720                                 set(REMLIB "")
721                         endif()
722                 endforeach()
723                 if(REMLIB)
724                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
725                         list(APPEND REM_MSG ${REMLIB})
726                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
727                 endif()
728         endforeach()
729         if(REM_MSG)
730                 list(SORT REM_MSG)
731                 message(STATUS "Blender Skipping: (${REM_MSG})")
732         endif()
733         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
734 #else()
735 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
736 #endif()
737
738 setup_liblinks(blender)