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