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