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