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