complete the language-select feature
[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
362                                 ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
363                                 ${CMAKE_SOURCE_DIR}/release/bin/.blender/fonts
364                         DESTINATION ${TARGETDIR_VER}/datafiles
365                         PATTERN ".svn" EXCLUDE
366                 )
367         endif()
368
369                 # plugins in blender 2.5 don't work at the moment.
370                 #
371                 # install(
372                 #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
373                 #       DESTINATION ${TARGETDIR_VER}
374                 #       PATTERN ".svn" EXCLUDE
375                 # )
376
377         if(WITH_PYTHON)
378                 # install(CODE "message(\"copying blender scripts...\")")
379                 install(
380                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
381                         DESTINATION ${TARGETDIR_VER}
382                         PATTERN ".svn" EXCLUDE
383                         PATTERN "__pycache__" EXCLUDE
384                 )
385
386                 if(WITH_PYTHON_INSTALL)
387                         # Copy the systems python into the install directory
388                         # Scons copy in tools/Blender.py
389                         # install(CODE "message(\"copying a subset of the systems python...\")")
390                         install(
391                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
392                                 DESTINATION ${TARGETDIR_VER}/python/lib
393                                 PATTERN ".svn" EXCLUDE
394                                 PATTERN "__pycache__" EXCLUDE               # * any cache *
395                                 PATTERN "distutils" EXCLUDE                 # ./distutils
396                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
397                                 PATTERN "config" EXCLUDE                    # ./config
398                                 PATTERN "config-*" EXCLUDE                  # ./config-*
399                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
400                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
401                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
402                                 PATTERN "idlelib" EXCLUDE                   # ./idlelib
403                                 PATTERN "test" EXCLUDE                      # ./test
404                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
405                                 PATTERN "turtle.py" EXCLUDE                                     # ./turtle.py
406                         )
407
408                         # # doesnt work, todo
409                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
410                 endif()
411         endif()
412 elseif(WIN32)
413
414         set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
415
416         install(  # same as linux!, deduplicate
417                 CODE
418                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
419         )
420
421         install(  # same as linux!, deduplicate
422                 FILES ${BLENDER_TEXT_FILES}
423                 DESTINATION ${TARGETDIR}
424         )
425
426         install(  # same as linux!, deduplicate
427                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
428                 DESTINATION ${TARGETDIR_VER}
429         )
430
431         if(WITH_INTERNATIONAL) # same as linux!, deduplicate
432                 install(
433                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
434                         DESTINATION ${TARGETDIR_VER}
435                 )
436                 install(
437                         DIRECTORY
438                                 ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
439                                 ${CMAKE_SOURCE_DIR}/release/bin/.blender/fonts
440                         DESTINATION ${TARGETDIR_VER}/datafiles
441                         PATTERN ".svn" EXCLUDE
442                 )
443
444                 if(NOT CMAKE_CL_64)
445                         install(
446                                 FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
447                                 DESTINATION ${TARGETDIR}
448                         )
449
450                         install(
451                                 FILES ${LIBDIR}/iconv/lib/iconv.dll
452                                 DESTINATION ${TARGETDIR}
453                         )
454                 endif()
455         endif()
456
457         install( # same as linux!, deduplicate
458                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
459                 DESTINATION ${TARGETDIR_VER}/datafiles
460                 PATTERN ".svn" EXCLUDE
461         )
462
463         # plugins in blender 2.5 don't work at the moment.
464         #
465         # install(
466         #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
467         #       DESTINATION ${TARGETDIR_VER}
468         #       PATTERN ".svn" EXCLUDE
469         # )
470
471         if(WITH_PYTHON)
472                 # install(CODE "message(\"copying blender scripts...\")")
473                 install(  # same as linux!, deduplicate
474                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
475                         DESTINATION ${TARGETDIR_VER}
476                         PATTERN ".svn" EXCLUDE
477                         PATTERN "__pycache__" EXCLUDE
478                 )
479
480                 install(
481                         FILES ${LIBDIR}/python/lib/python32.dll
482                         DESTINATION ${TARGETDIR}
483                         CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
484                 )
485
486                 install(
487                         FILES ${LIBDIR}/python/lib/python32_d.dll
488                         DESTINATION ${TARGETDIR}
489                         CONFIGURATIONS Debug
490                 )
491
492                 if(WITH_PYTHON_INSTALL)
493                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
494
495                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
496                         install(
497                                 CODE
498                                 "
499                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
500                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\")
501                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\")
502                                 message(\"done creating dir\")
503                                 "
504                         )
505
506                         install(
507                                 CODE
508                                 "
509                                 if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
510                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
511                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32_d.tar.gz\")
512                                 else()
513                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
514                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
515                                 endif()
516                                 "
517                         )
518
519                         # doesnt work, todo
520                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
521                 endif()
522         endif()
523
524         if(CMAKE_CL_64)
525                 # gettext and png are statically linked on win64
526                 install(
527                         FILES ${LIBDIR}/zlib/lib/zlib.dll
528                         DESTINATION ${TARGETDIR}
529                 )
530         else()
531                 install(
532                         FILES
533                                 ${LIBDIR}/png/lib/libpng.dll
534                                 ${LIBDIR}/zlib/lib/zlib.dll
535                         DESTINATION ${TARGETDIR}
536                 )
537         endif()
538
539         if(MSVC)
540                 install(
541                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
542                         DESTINATION ${TARGETDIR}
543                 )
544         else()
545                 install(
546                         FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
547                         DESTINATION ${TARGETDIR}
548                 )
549         endif()
550
551         if(WITH_CODEC_FFMPEG)
552                 install(
553                         FILES
554                                 ${LIBDIR}/ffmpeg/lib/avcodec-52.dll
555                                 ${LIBDIR}/ffmpeg/lib/avformat-52.dll
556                                 ${LIBDIR}/ffmpeg/lib/avdevice-52.dll
557                                 ${LIBDIR}/ffmpeg/lib/avutil-50.dll
558                                 ${LIBDIR}/ffmpeg/lib/swscale-0.dll
559                         DESTINATION ${TARGETDIR}
560                 )
561
562         endif()
563
564         if(WITH_CODEC_SNDFILE)
565                 install(
566                         FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
567                         DESTINATION ${TARGETDIR}
568                 )
569         endif()
570
571         if(WITH_OPENAL)
572                 install(
573                         FILES
574                                 ${LIBDIR}/openal/lib/OpenAL32.dll
575                                 ${LIBDIR}/openal/lib/wrap_oal.dll
576                         DESTINATION ${TARGETDIR}
577                 )
578         endif()
579
580         if(WITH_SDL)
581                 if(NOT CMAKE_CL_64)
582                         install(
583                                 FILES ${LIBDIR}/sdl/lib/SDL.dll
584                                 DESTINATION ${TARGETDIR}
585                         )
586                 endif()
587         endif()
588
589         if(NOT CMAKE_CL_64)
590                 install(
591                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
592                         DESTINATION ${TARGETDIR}
593                 )
594         else()
595                 install(
596                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
597                         DESTINATION ${TARGETDIR}
598                 )
599         endif()
600
601 elseif(APPLE)
602         set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
603         set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
604         set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
605
606         # setup Info.plist
607         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
608
609         set_target_properties(blender PROPERTIES
610                 MACOSX_BUNDLE_INFO_PLIST ${SOURCEINFO}
611                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
612                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
613
614         # important to make a clean  install each time else old scripts get loaded.
615         install(
616                 CODE
617                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
618         )
619
620         # message after building.
621         add_custom_command(
622                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
623                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${TARGETDIR_VER}'
624         )
625
626         # handy install macro to exclude files, we use \$ escape for the "to"
627         # argument when calling so ${BUILD_TYPE} does not get expanded
628         macro(install_dir from to)
629                 install(
630                         DIRECTORY ${from}
631                         DESTINATION ${to}
632                         PATTERN ".svn" EXCLUDE
633                         PATTERN "*.pyc" EXCLUDE
634                         PATTERN "*.pyo" EXCLUDE
635                         PATTERN "*.orig" EXCLUDE
636                         PATTERN "*.rej" EXCLUDE
637                         PATTERN "__pycache__" EXCLUDE
638                         PATTERN "__MACOSX" EXCLUDE
639                         PATTERN ".DS_Store" EXCLUDE
640                 )
641         endmacro()
642
643         # install release and app files
644         install(
645                 FILES ${BLENDER_TEXT_FILES}
646                 DESTINATION ${TARGETDIR}
647         )
648
649         install(
650                 FILES ${SOURCEDIR}/Contents/PkgInfo
651                 DESTINATION ${TARGETDIR}/blender.app/Contents
652         )
653
654         install_dir(
655                 ${SOURCEDIR}/Contents/Resources
656                 \${TARGETDIR}/blender.app/Contents/
657         )
658
659         install(
660                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
661                 DESTINATION ${TARGETDIR_VER}
662         )
663
664         # localization
665         if(WITH_INTERNATIONAL)
666                 install(
667                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
668                         DESTINATION ${TARGETDIR_VER}/datafiles
669                 )
670
671                 install_dir(
672                         DIRECTORY
673                                         ${CMAKE_SOURCE_DIR}/release/bin/.blender/fonts
674                         \${TARGETDIR_VER}/datafiles/
675                 )
676
677                 install_dir(
678                         DIRECTORY
679                                         ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
680                         \${TARGETDIR_VER}/datafiles/
681                 )
682         endif()
683
684         # python
685         if(WITH_PYTHON)
686                 # the python zip is first extract as part of the build process,
687                 # and then later installed as part of make install. this is much
688                 # quicker, and means we can easily exclude files on copy
689                 add_custom_target(
690                         extractpyzip
691                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
692
693                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
694                         
695                 add_custom_command(
696                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
697                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
698                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
699                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
700                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
701                 
702                 add_dependencies(blender extractpyzip)
703
704                 # copy extracted python files
705                 install_dir(
706                         ${CMAKE_CURRENT_BINARY_DIR}/python
707                         \${TARGETDIR_VER}
708                 )
709
710                 # copy scripts
711                 install_dir(
712                         ${CMAKE_SOURCE_DIR}/release/scripts
713                         \${TARGETDIR_VER}
714                 )
715         endif()
716 endif()
717
718 unset(BLENDER_TEXT_FILES)
719
720
721 # -----------------------------------------------------------------------------
722 # Setup link libs
723
724 add_dependencies(blender makesdna)
725
726 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
727
728 set(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
729
730 if(WITH_MOD_FLUID)
731         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
732 endif()
733
734
735 #if(UNIX)
736         # Sort libraries
737         set(BLENDER_SORTED_LIBS
738                 bf_windowmanager
739
740                 bf_editor_space_api
741                 bf_editor_space_action
742                 bf_editor_space_buttons
743                 bf_editor_space_console
744                 bf_editor_space_file
745                 bf_editor_space_graph
746                 bf_editor_space_image
747                 bf_editor_space_info
748                 bf_editor_space_logic
749                 bf_editor_space_nla
750                 bf_editor_space_node
751                 bf_editor_space_outliner
752                 bf_editor_space_script
753                 bf_editor_space_sequencer
754                 bf_editor_space_sound
755                 bf_editor_space_time
756                 bf_editor_space_userpref
757                 bf_editor_space_view3d
758
759                 bf_editor_text
760                 bf_editor_transform
761                 bf_editor_util
762                 bf_editor_uvedit
763                 bf_editor_curve
764                 bf_editor_armature
765                 bf_editor_gpencil
766                 bf_editor_interface
767                 bf_editor_mesh
768                 bf_editor_metaball
769                 bf_editor_object
770                 bf_editor_physics
771                 bf_editor_render
772                 bf_editor_screen
773                 bf_editor_sculpt_paint
774                 bf_editor_sound
775                 bf_editor_animation
776                 bf_editor_datafiles
777
778                 bf_render
779                 bf_intern_opennl
780                 bf_python
781                 bf_python_ext
782                 bf_ikplugin
783                 bf_modifiers
784                 bf_blenkernel
785                 bf_nodes
786                 bf_gpu
787                 bf_blenloader
788                 bf_blenlib
789                 bf_intern_ghost
790                 bf_intern_string
791                 bf_blenpluginapi
792                 bf_imbuf
793                 bf_avi
794                 bf_imbuf_cineon
795                 bf_imbuf_openexr
796                 bf_imbuf_dds
797                 bf_collada
798                 bf_intern_bsp
799                 bf_intern_bop
800                 bf_intern_decimate
801                 bf_intern_elbeem
802                 bf_intern_ik
803                 bf_intern_memutil
804                 bf_intern_guardedalloc
805                 bf_intern_ctr
806                 ge_blen_routines
807                 ge_converter
808                 ge_phys_dummy
809                 ge_phys_bullet
810                 bf_intern_smoke
811                 extern_minilzo
812                 extern_lzma
813                 ge_logic_ketsji
814                 ge_phys_common
815                 ge_logic
816                 ge_rasterizer
817                 ge_oglrasterizer
818                 ge_logic_expressions
819                 ge_scenegraph
820                 ge_logic_network
821                 bf_python # duplicate for BPY_driver_exec
822                 ge_logic_ngnetwork
823                 extern_bullet
824                 ge_logic_loopbacknetwork
825                 bf_intern_moto
826                 extern_openjpeg
827                 extern_redcode
828                 ge_videotex
829                 bf_rna
830                 bf_dna
831                 bf_blenfont
832                 bf_intern_audaspace
833                 bf_intern_mikktspace
834         )
835
836         if(WITH_MOD_CLOTH_ELTOPO)
837                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
838         endif()
839
840         if(WITH_BUILTIN_GLEW)
841                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
842         endif()
843
844         if(WITH_BINRELOC)
845                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
846         endif()
847
848         if(WITH_CXX_GUARDEDALLOC)
849                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
850         endif()
851
852         if(WITH_IK_ITASC)
853                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
854         endif()
855
856         if(WITH_CODEC_QUICKTIME)
857                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
858         endif()
859
860         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
861                 set(REMLIB ${SORTLIB})
862                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
863                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
864                                 set(REMLIB "")
865                         endif()
866                 endforeach()
867                 if(REMLIB)
868                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
869                         list(APPEND REM_MSG ${REMLIB})
870                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
871                 endif()
872         endforeach()
873         if(REM_MSG)
874                 list(SORT REM_MSG)
875                 message(STATUS "Blender Skipping: (${REM_MSG})")
876         endif()
877         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
878         
879         unset(SEARCHLIB)
880         unset(SORTLIB)
881         unset(REMLIB)
882         unset(REM_MSG)
883         
884 #else()
885 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
886 #endif()
887
888 setup_liblinks(blender)