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