- CMake, print message to run 'make install', this is new and should help avoid confu...
[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 ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${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_VER}/../
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 ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/datafiles/locale
383                         PATTERN ".svn" EXCLUDE
384                 )
385
386                 install( # same as linux!, deduplicate
387                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
388                         DESTINATION ${TARGETDIR_VER}/../
389                         PATTERN ".svn" EXCLUDE
390                 )
391
392                 # plugins in blender 2.5 don't work at the moment.
393                 #
394                 # install(
395                 #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
396                 #       DESTINATION ${TARGETDIR_VER}/
397                 #       PATTERN ".svn" EXCLUDE
398                 # )
399
400                 if(WITH_PYTHON)
401                         # install(CODE "message(\"copying blender scripts...\")")
402                         install(  # same as linux!, deduplicate
403                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
404                                 DESTINATION ${TARGETDIR_VER}/
405                                 PATTERN ".svn" EXCLUDE
406                                 PATTERN "__pycache__" EXCLUDE
407                         )
408
409                         # TODO, multiple targets?
410                         install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS Release)
411                         install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS RelWithDebInfo)
412                         install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS MinSizeRel)
413
414                         install(
415                                 FILES ${LIBDIR}/python/lib/python32_d.dll
416                                 DESTINATION ${TARGETDIR}/
417                                 CONFIGURATIONS Debug
418                         )
419
420                         if(WITH_PYTHON_INSTALL)
421                                 #~ # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
422                                 # install(CODE "message(\"copying a subset of the systems python...\")")
423
424                                 install(
425                                         CODE
426                                         "execute_process(COMMAND ${CMAKE_COMMAND}
427                                         -E make_directory ${TARGETDIR_VER}/python/lib/)"
428                                 )
429
430                                 install(
431                                         CODE
432                                         "
433                                         if(BUILD_TYPE MATCHES \"Debug\")
434                                                 set(PYBUNDLE \"python32_d.tar.gz\")
435                                         else()
436                                                 set(PYBUNDLE \"python32.tar.gz\")
437                                         endif()
438
439                                         execute_process(COMMAND ${CMAKE_COMMAND}
440                                                 -E chdir ${TARGETDIR_VER}/python/lib/
441                                                 ${CMAKE_COMMAND} -E tar xzfv ${LIBDIR}/release/\${PYBUNDLE})
442                                         "
443                                 )
444
445                                 # doesnt work, todo
446                                 # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
447                         endif()
448                 endif()
449
450                 if(CMAKE_CL_64)
451                         # gettext and png are statically linked on win64
452                         install(
453                                 FILES ${LIBDIR}/zlib/lib/zlib.dll
454                                 DESTINATION ${TARGETDIR}/
455                         )
456                 else()
457                         install(
458                                 FILES
459                                 ${LIBDIR}/png/lib/libpng.dll
460                                 ${LIBDIR}/zlib/lib/zlib.dll
461                                 DESTINATION ${TARGETDIR}/
462                         )
463                 endif()
464
465                 if(MSVC)
466                         install(
467                                 FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
468                                 DESTINATION ${TARGETDIR}/
469                         )
470                 else()
471                         install(
472                                 FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
473                                 DESTINATION ${TARGETDIR}/
474                         )
475                 endif()
476
477                 if(WITH_CODEC_FFMPEG)
478                         install(
479                                 FILES
480                                 ${LIBDIR}/ffmpeg/lib/avcodec-52.dll
481                                 ${LIBDIR}/ffmpeg/lib/avformat-52.dll
482                                 ${LIBDIR}/ffmpeg/lib/avdevice-52.dll
483                                 ${LIBDIR}/ffmpeg/lib/avutil-50.dll
484                                 ${LIBDIR}/ffmpeg/lib/swscale-0.dll
485                                 DESTINATION ${TARGETDIR}/
486                         )
487
488                 endif()
489
490                 if(WITH_CODEC_SNDFILE)
491                         install(
492                                 FILES
493                                 ${LIBDIR}/sndfile/lib/libsndfile-1.dll
494                                 DESTINATION ${TARGETDIR}/
495                         )
496                 endif()
497
498                 if(WITH_OPENAL)
499                         install(
500                                 FILES
501                                 ${LIBDIR}/openal/lib/OpenAL32.dll
502                                 ${LIBDIR}/openal/lib/wrap_oal.dll
503                                 DESTINATION ${TARGETDIR}/
504                         )
505                 endif()
506
507                 if(WITH_SDL)
508                         if(NOT CMAKE_CL_64)
509                                 install(
510                                         FILES
511                                         ${LIBDIR}/sdl/lib/SDL.dll
512                                         DESTINATION ${TARGETDIR}/
513                                 )
514                         endif()
515                 endif()
516
517         elseif(APPLE)
518                 # TODO, APPLE needs a 'make install' target like win32 and unix
519
520                 set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
521                 set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
522                 set(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
523
524                 add_custom_command(
525                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
526                         COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
527                 )
528
529                 add_custom_command(
530                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
531                         COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
532                         COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
533                         COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
534                         COMMAND cat ${SOURCEINFO} | sed s/VERSION/${BLENDER_VERSION}${BLENDER_VERSION_CHAR}/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
535                         COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
536                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
537                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
538                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
539                 )
540
541                 if(WITH_INTERNATIONAL)
542                         add_custom_command(
543                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
544                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
545                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
546                         )
547                 endif()
548
549                 if(WITH_PYTHON)
550                         set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
551                         add_custom_command(
552                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
553                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/
554                                 COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
555                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
556                                 COMMAND find ${TARGETDIR}/blender.app -name '*.py[co]' -prune -exec rm -rf {} '\;'
557                                 COMMAND find ${TARGETDIR}/blender.app -name '__pycache__' -exec rmdir {} '+'
558                         )
559                 endif()
560
561                 add_custom_command(
562                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
563                         COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
564                         COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
565                         COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;"
566                 )
567         endif()
568
569 endif()
570
571 add_dependencies(blender makesdna)
572
573 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
574
575 set(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
576
577 if(WITH_MOD_FLUID)
578         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
579 endif()
580
581
582 #if(UNIX)
583         # Sort libraries
584         set(BLENDER_SORTED_LIBS
585                 bf_windowmanager
586
587                 bf_editor_space_api
588                 bf_editor_space_action
589                 bf_editor_space_buttons
590                 bf_editor_space_console
591                 bf_editor_space_file
592                 bf_editor_space_graph
593                 bf_editor_space_image
594                 bf_editor_space_info
595                 bf_editor_space_logic
596                 bf_editor_space_nla
597                 bf_editor_space_node
598                 bf_editor_space_outliner
599                 bf_editor_space_script
600                 bf_editor_space_sequencer
601                 bf_editor_space_sound
602                 bf_editor_space_time
603                 bf_editor_space_userpref
604                 bf_editor_space_view3d
605
606                 bf_editor_text
607                 bf_editor_transform
608                 bf_editor_util
609                 bf_editor_uvedit
610                 bf_editor_curve
611                 bf_editor_armature
612                 bf_editor_gpencil
613                 bf_editor_interface
614                 bf_editor_mesh
615                 bf_editor_metaball
616                 bf_editor_object
617                 bf_editor_physics
618                 bf_editor_render
619                 bf_editor_screen
620                 bf_editor_sculpt_paint
621                 bf_editor_sound
622                 bf_editor_animation
623                 bf_editor_datafiles
624
625                 bf_render
626                 bf_intern_opennl
627                 bf_python
628                 bf_python_ext
629                 bf_ikplugin
630                 bf_modifiers
631                 bf_blenkernel
632                 bf_nodes
633                 bf_gpu
634                 bf_blenloader
635                 bf_blenlib
636                 bf_intern_ghost
637                 bf_intern_string
638                 bf_blenpluginapi
639                 bf_imbuf
640                 bf_avi
641                 bf_imbuf_cineon
642                 bf_imbuf_openexr
643                 bf_imbuf_dds
644                 bf_readblenfile
645                 bf_collada
646                 bf_intern_bsp
647                 bf_intern_bop
648                 bf_gen_system
649                 bf_intern_decimate
650                 bf_intern_elbeem
651                 bf_intern_ik
652                 bf_intern_memutil
653                 bf_intern_guardedalloc
654                 bf_intern_ctr
655                 ge_blen_routines
656                 ge_converter
657                 ge_phys_dummy
658                 ge_phys_bullet
659                 bf_intern_smoke
660                 extern_minilzo
661                 extern_lzma
662                 ge_logic_ketsji
663                 ge_phys_common
664                 ge_logic
665                 ge_rasterizer
666                 ge_oglrasterizer
667                 ge_logic_expressions
668                 ge_scenegraph
669                 ge_logic_network
670                 bf_gen_system
671                 bf_python # duplicate for BPY_driver_exec
672                 ge_logic_ngnetwork
673                 extern_bullet
674                 ge_logic_loopbacknetwork
675                 bf_intern_moto
676                 extern_glew
677                 extern_openjpeg
678                 extern_redcode
679                 ge_videotex
680                 bf_rna
681                 bf_dna
682                 bf_blenfont
683                 bf_intern_audaspace
684                 bf_intern_mikktspace
685         )
686
687         if(WITH_BINRELOC)
688                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
689         endif()
690
691         if(WITH_CXX_GUARDEDALLOC)
692                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
693         endif()
694
695         if(WITH_IK_ITASC)
696                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
697         endif()
698
699         if(WITH_CODEC_QUICKTIME)
700                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
701         endif()
702
703         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
704                 set(REMLIB ${SORTLIB})
705                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
706                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
707                                 set(REMLIB "")
708                         endif()
709                 endforeach()
710                 if(REMLIB)
711                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
712                         list(APPEND REM_MSG ${REMLIB})
713                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
714                 endif()
715         endforeach()
716         if(REM_MSG)
717                 list(SORT REM_MSG)
718                 message(STATUS "Blender Skipping: (${REM_MSG})")
719         endif()
720         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
721 #else()
722 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
723 #endif()
724
725 setup_liblinks(blender)