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