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