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