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