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