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