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