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