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