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