Merging r41120 through from trunk r41139 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(WITH_SDL)
97         add_definitions(-DWITH_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                         DIRECTORY
360                                 ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
361                                 ${CMAKE_SOURCE_DIR}/release/bin/.blender/fonts
362                         DESTINATION ${TARGETDIR_VER}/datafiles
363                         PATTERN ".svn" EXCLUDE
364                 )
365         endif()
366
367                 # plugins in blender 2.5 don't work at the moment.
368                 #
369                 # install(
370                 #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
371                 #       DESTINATION ${TARGETDIR_VER}
372                 #       PATTERN ".svn" EXCLUDE
373                 # )
374
375         if(WITH_PYTHON)
376                 # install(CODE "message(\"copying blender scripts...\")")
377                 install(
378                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
379                         DESTINATION ${TARGETDIR_VER}
380                         PATTERN ".svn" EXCLUDE
381                         PATTERN "__pycache__" EXCLUDE
382                 )
383
384                 if(WITH_PYTHON_INSTALL)
385                         # Copy the systems python into the install directory
386                         # Scons copy in tools/Blender.py
387                         # install(CODE "message(\"copying a subset of the systems python...\")")
388                         install(
389                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
390                                 DESTINATION ${TARGETDIR_VER}/python/lib
391                                 PATTERN ".svn" EXCLUDE
392                                 PATTERN "__pycache__" EXCLUDE               # * any cache *
393                                 PATTERN "distutils" EXCLUDE                 # ./distutils
394                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
395                                 PATTERN "config" EXCLUDE                    # ./config
396                                 PATTERN "config-*" EXCLUDE                  # ./config-*
397                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
398                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
399                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
400                                 PATTERN "idlelib" EXCLUDE                   # ./idlelib
401                                 PATTERN "test" EXCLUDE                      # ./test
402                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
403                                 PATTERN "turtle.py" EXCLUDE                                     # ./turtle.py
404                         )
405
406                         # # doesnt work, todo
407                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
408                 endif()
409         endif()
410 elseif(WIN32)
411
412         set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
413
414         install(  # same as linux!, deduplicate
415                 CODE
416                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
417         )
418
419         install(  # same as linux!, deduplicate
420                 FILES ${BLENDER_TEXT_FILES}
421                 DESTINATION ${TARGETDIR}
422         )
423
424         install(  # same as linux!, deduplicate
425                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
426                 DESTINATION ${TARGETDIR_VER}
427         )
428
429         if(WITH_INTERNATIONAL) # same as linux!, deduplicate
430                 install(
431                         DIRECTORY
432                                 ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
433                                 ${CMAKE_SOURCE_DIR}/release/bin/.blender/fonts
434                         DESTINATION ${TARGETDIR_VER}/datafiles
435                         PATTERN ".svn" EXCLUDE
436                 )
437
438                 install(
439                         FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
440                         DESTINATION ${TARGETDIR}
441                 )
442
443                 if(NOT CMAKE_CL_64)
444                         install(
445                                 FILES ${LIBDIR}/iconv/lib/iconv.dll
446                                 DESTINATION ${TARGETDIR}
447                         )
448                 endif()
449         endif()
450
451         # plugins in blender 2.5 don't work at the moment.
452         #
453         # install(
454         #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
455         #       DESTINATION ${TARGETDIR_VER}
456         #       PATTERN ".svn" EXCLUDE
457         # )
458
459         if(WITH_PYTHON)
460                 # install(CODE "message(\"copying blender scripts...\")")
461                 install(  # same as linux!, deduplicate
462                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
463                         DESTINATION ${TARGETDIR_VER}
464                         PATTERN ".svn" EXCLUDE
465                         PATTERN "__pycache__" EXCLUDE
466                 )
467
468                 install(
469                         FILES ${LIBDIR}/python/lib/python32.dll
470                         DESTINATION ${TARGETDIR}
471                         CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
472                 )
473
474                 install(
475                         FILES ${LIBDIR}/python/lib/python32_d.dll
476                         DESTINATION ${TARGETDIR}
477                         CONFIGURATIONS Debug
478                 )
479
480                 if(WITH_PYTHON_INSTALL)
481                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
482
483                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
484                         install(
485                                 CODE
486                                 "
487                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
488                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\")
489                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\")
490                                 message(\"done creating dir\")
491                                 "
492                         )
493
494                         install(
495                                 CODE
496                                 "
497                                 if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
498                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
499                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32_d.tar.gz\")
500                                 else()
501                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
502                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
503                                 endif()
504                                 "
505                         )
506
507                         # doesnt work, todo
508                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
509                 endif()
510         endif()
511
512         if(CMAKE_CL_64)
513                 # gettext and png are statically linked on win64
514                 install(
515                         FILES ${LIBDIR}/zlib/lib/zlib.dll
516                         DESTINATION ${TARGETDIR}
517                 )
518         else()
519                 install(
520                         FILES
521                                 ${LIBDIR}/png/lib/libpng.dll
522                                 ${LIBDIR}/zlib/lib/zlib.dll
523                         DESTINATION ${TARGETDIR}
524                 )
525         endif()
526
527         if(MSVC)
528                 install(
529                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
530                         DESTINATION ${TARGETDIR}
531                 )
532         else()
533                 install(
534                         FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
535                         DESTINATION ${TARGETDIR}
536                 )
537         endif()
538
539         if(WITH_CODEC_FFMPEG)
540                 install(
541                         FILES
542                                 ${LIBDIR}/ffmpeg/lib/avcodec-53.dll
543                                 ${LIBDIR}/ffmpeg/lib/avformat-53.dll
544                                 ${LIBDIR}/ffmpeg/lib/avdevice-53.dll
545                                 ${LIBDIR}/ffmpeg/lib/avutil-51.dll
546                                 ${LIBDIR}/ffmpeg/lib/swscale-2.dll
547                         DESTINATION ${TARGETDIR}
548                 )
549
550         endif()
551
552         if(WITH_CODEC_SNDFILE)
553                 install(
554                         FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
555                         DESTINATION ${TARGETDIR}
556                 )
557         endif()
558
559         if(WITH_OPENAL)
560                 install(
561                         FILES
562                                 ${LIBDIR}/openal/lib/OpenAL32.dll
563                                 ${LIBDIR}/openal/lib/wrap_oal.dll
564                         DESTINATION ${TARGETDIR}
565                 )
566         endif()
567
568         if(WITH_SDL)
569                 if(NOT CMAKE_CL_64)
570                         install(
571                                 FILES ${LIBDIR}/sdl/lib/SDL.dll
572                                 DESTINATION ${TARGETDIR}
573                         )
574                 endif()
575         endif()
576
577         if(NOT CMAKE_CL_64)
578                 install(
579                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
580                         DESTINATION ${TARGETDIR}
581                 )
582         endif()
583                 
584         install( # x86 builds can run on x64 Windows, so this is required at all times
585                 FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
586                 DESTINATION ${TARGETDIR}
587         )       
588
589 elseif(APPLE)
590         set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
591         set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
592         set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
593
594         # setup Info.plist
595         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
596
597         set_target_properties(blender PROPERTIES
598                 MACOSX_BUNDLE_INFO_PLIST ${SOURCEINFO}
599                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
600                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
601
602         # important to make a clean  install each time else old scripts get loaded.
603         install(
604                 CODE
605                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
606         )
607
608         # message after building.
609         add_custom_command(
610                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
611                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${TARGETDIR_VER}'
612         )
613
614         # handy install macro to exclude files, we use \$ escape for the "to"
615         # argument when calling so ${BUILD_TYPE} does not get expanded
616         macro(install_dir from to)
617                 install(
618                         DIRECTORY ${from}
619                         DESTINATION ${to}
620                         PATTERN ".svn" EXCLUDE
621                         PATTERN "*.pyc" EXCLUDE
622                         PATTERN "*.pyo" EXCLUDE
623                         PATTERN "*.orig" EXCLUDE
624                         PATTERN "*.rej" EXCLUDE
625                         PATTERN "__pycache__" EXCLUDE
626                         PATTERN "__MACOSX" EXCLUDE
627                         PATTERN ".DS_Store" EXCLUDE
628                 )
629         endmacro()
630
631         # install release and app files
632         install(
633                 FILES ${BLENDER_TEXT_FILES}
634                 DESTINATION ${TARGETDIR}
635         )
636
637         install(
638                 FILES ${SOURCEDIR}/Contents/PkgInfo
639                 DESTINATION ${TARGETDIR}/blender.app/Contents
640         )
641
642         install_dir(
643                 ${SOURCEDIR}/Contents/Resources
644                 \${TARGETDIR}/blender.app/Contents/
645         )
646
647         install(
648                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
649                 DESTINATION ${TARGETDIR_VER}
650         )
651
652         # localization
653         if(WITH_INTERNATIONAL)
654                 install(
655                         DIRECTORY
656                                 ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
657                                 ${CMAKE_SOURCE_DIR}/release/bin/.blender/fonts
658                         DESTINATION ${TARGETDIR_VER}/datafiles
659                         PATTERN ".svn" EXCLUDE
660                 )
661         endif()
662
663         # python
664         if(WITH_PYTHON)
665                 # the python zip is first extract as part of the build process,
666                 # and then later installed as part of make install. this is much
667                 # quicker, and means we can easily exclude files on copy
668                 add_custom_target(
669                         extractpyzip
670                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
671
672                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
673
674                 add_custom_command(
675                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
676                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
677                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
678                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
679                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
680
681                 add_dependencies(blender extractpyzip)
682
683                 # copy extracted python files
684                 install_dir(
685                         ${CMAKE_CURRENT_BINARY_DIR}/python
686                         \${TARGETDIR_VER}
687                 )
688
689                 # copy scripts
690                 install_dir(
691                         ${CMAKE_SOURCE_DIR}/release/scripts
692                         \${TARGETDIR_VER}
693                 )
694         endif()
695
696         # install blenderplayer bundle - copy of blender.app above. re-using macros et al
697         # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
698         if(WITH_GAMEENGINE AND WITH_PLAYER)
699                 set(PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blenderplayer.app)
700                 set(PLAYER_SOURCEINFO ${PLAYER_SOURCEDIR}/Contents/Info.plist)
701                 set(PLAYER_TARGETDIR_VER ${TARGETDIR}/blenderplayer.app/Contents/MacOS/${BLENDER_VERSION})
702
703
704                 # important to make a clean  install each time else old scripts get loaded.
705                 install(
706                         CODE
707                         "file(REMOVE_RECURSE ${PLAYER_TARGETDIR_VER})"
708                 )
709
710                 install(
711                         FILES ${PLAYER_SOURCEDIR}/Contents/PkgInfo
712                         DESTINATION ${TARGETDIR}/blenderplayer.app/Contents
713                 )
714
715                 install_dir(
716                         ${PLAYER_SOURCEDIR}/Contents/Resources
717                         \${TARGETDIR}/blenderplayer.app/Contents/
718                 )
719
720                 # python
721                 if(WITH_PYTHON)
722                         add_custom_command(
723                                 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
724                                 COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
725                                 COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
726                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
727                                 DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
728
729                         # copy extracted python files
730                         install_dir(
731                                 ${CMAKE_CURRENT_BINARY_DIR}/python
732                                 \${PLAYER_TARGETDIR_VER}
733                         )
734                 endif()
735
736         endif()
737 endif()
738
739 unset(BLENDER_TEXT_FILES)
740
741
742 # -----------------------------------------------------------------------------
743 # Setup link libs
744
745 add_dependencies(blender makesdna)
746
747 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
748
749 set(BLENDER_LINK_LIBS
750         ${BLENDER_LINK_LIBS}
751         bf_windowmanager
752         bf_render
753 )
754
755 if(WITH_MOD_FLUID)
756         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
757 endif()
758
759 #if(UNIX)
760         # Sort libraries
761         set(BLENDER_SORTED_LIBS
762                 bf_windowmanager
763
764                 bf_editor_space_api
765                 bf_editor_space_action
766                 bf_editor_space_buttons
767                 bf_editor_space_console
768                 bf_editor_space_file
769                 bf_editor_space_graph
770                 bf_editor_space_image
771                 bf_editor_space_info
772                 bf_editor_space_logic
773                 bf_editor_space_nla
774                 bf_editor_space_node
775                 bf_editor_space_outliner
776                 bf_editor_space_script
777                 bf_editor_space_sequencer
778                 bf_editor_space_sound
779                 bf_editor_space_time
780                 bf_editor_space_userpref
781                 bf_editor_space_view3d
782                 bf_editor_space_clip
783
784                 bf_editor_text
785                 bf_editor_transform
786                 bf_editor_util
787                 bf_editor_uvedit
788                 bf_editor_curve
789                 bf_editor_armature
790                 bf_editor_gpencil
791                 bf_editor_interface
792                 bf_editor_mesh
793                 bf_editor_metaball
794                 bf_editor_object
795                 bf_editor_physics
796                 bf_editor_render
797                 bf_editor_screen
798                 bf_editor_sculpt_paint
799                 bf_editor_sound
800                 bf_editor_animation
801                 bf_editor_datafiles
802
803                 bf_render
804                 bf_intern_opennl
805                 bf_python
806                 bf_python_ext
807                 bf_python_mathutils
808                 bf_ikplugin
809                 bf_modifiers
810                 bf_blenkernel
811                 bf_nodes
812                 bf_gpu
813                 bf_blenloader
814                 bf_blenlib
815                 bf_intern_ghost
816                 bf_intern_string
817                 bf_blenpluginapi
818                 bf_imbuf
819                 bf_avi
820                 bf_imbuf_cineon
821                 bf_imbuf_openexr
822                 bf_imbuf_dds
823                 bf_collada
824                 bf_intern_bsp
825                 bf_intern_bop
826                 bf_intern_decimate
827                 bf_intern_elbeem
828                 bf_intern_ik
829                 bf_intern_memutil
830                 bf_intern_guardedalloc
831                 bf_intern_ctr
832                 ge_blen_routines
833                 ge_converter
834                 ge_phys_dummy
835                 ge_phys_bullet
836                 bf_intern_smoke
837                 extern_minilzo
838                 extern_lzma
839                 extern_colamd
840                 ge_logic_ketsji
841                 extern_recastnavigation
842                 ge_phys_common
843                 ge_logic
844                 ge_rasterizer
845                 ge_oglrasterizer
846                 ge_logic_expressions
847                 ge_scenegraph
848                 ge_logic_network
849                 ge_logic_ngnetwork
850                 extern_bullet
851                 ge_logic_loopbacknetwork
852                 bf_intern_moto
853                 extern_openjpeg
854                 extern_redcode
855                 ge_videotex
856                 bf_rna
857                 bf_dna
858                 bf_blenfont
859                 bf_intern_audaspace
860                 bf_intern_mikktspace
861         )
862
863         if(WITH_LIBMV)
864                 list(APPEND BLENDER_SORTED_LIBS extern_libmv)
865         endif()
866
867         if(WITH_MOD_CLOTH_ELTOPO)
868                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
869         endif()
870
871         if(WITH_BUILTIN_GLEW)
872                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
873         endif()
874
875         if(WITH_BINRELOC)
876                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
877         endif()
878
879         if(WITH_CXX_GUARDEDALLOC)
880                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
881         endif()
882
883         if(WITH_IK_ITASC)
884                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
885         endif()
886
887         if(WITH_CODEC_QUICKTIME)
888                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
889         endif()
890
891         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
892                 set(REMLIB ${SORTLIB})
893                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
894                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
895                                 set(REMLIB "")
896                         endif()
897                 endforeach()
898                 if(REMLIB)
899                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
900                         list(APPEND REM_MSG ${REMLIB})
901                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
902                 endif()
903         endforeach()
904         if(REM_MSG)
905                 list(SORT REM_MSG)
906                 message(STATUS "Blender Skipping: (${REM_MSG})")
907         endif()
908         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
909
910         unset(SEARCHLIB)
911         unset(SORTLIB)
912         unset(REMLIB)
913         unset(REM_MSG)
914
915 #else()
916 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
917 #endif()
918
919 setup_liblinks(blender)