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