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