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