Cycles: Add support of Glog logging
[blender-staging.git] / source / creator / CMakeLists.txt
1 # ***** BEGIN GPL LICENSE BLOCK *****
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # The Original Code is Copyright (C) 2006, Blender Foundation
18 # All rights reserved.
19 #
20 # The Original Code is: all of this file.
21 #
22 # Contributor(s): Jacques Beaurain.
23 #
24 # ***** END GPL LICENSE BLOCK *****
25
26 setup_libdirs()
27
28 blender_include_dirs(
29         ../../intern/guardedalloc
30         ../blender/blenlib
31         ../blender/blenkernel
32         ../blender/blenloader
33         ../blender/editors/include
34         ../blender/makesrna
35         ../blender/imbuf
36         ../blender/render/extern/include
37         ../blender/makesdna
38         ../blender/gpu
39         ../blender/windowmanager
40 )
41
42 if(WIN32)
43         blender_include_dirs(../../intern/utfconv)
44 endif()
45
46 if(WITH_LIBMV)
47         blender_include_dirs(../../extern/libmv)
48         add_definitions(-DWITH_LIBMV)
49 endif()
50
51 if(WITH_CYCLES AND WITH_CYCLES_LOGGING)
52         blender_include_dirs(../../intern/cycles/blender)
53         add_definitions(-DWITH_CYCLES_LOGGING)
54 endif()
55
56 if(WITH_CODEC_FFMPEG)
57         add_definitions(-DWITH_FFMPEG)
58 endif()
59
60 if(WITH_PYTHON)
61         blender_include_dirs(../blender/python)
62         add_definitions(-DWITH_PYTHON)
63
64         if(WITH_PYTHON_SECURITY)
65                 add_definitions(-DWITH_PYTHON_SECURITY)
66         endif()
67 endif()
68
69 if(WITH_HEADLESS)
70         add_definitions(-DWITH_HEADLESS)
71 endif()
72
73 if(WITH_GAMEENGINE)
74         blender_include_dirs(../gameengine/BlenderRoutines)
75
76         add_definitions(-DWITH_GAMEENGINE)
77 endif()
78
79 if(WITH_SDL)
80         add_definitions(-DWITH_SDL)
81 endif()
82
83 if(WITH_BINRELOC)
84         add_definitions(-DWITH_BINRELOC)
85         blender_include_dirs(${BINRELOC_INCLUDE_DIRS})
86 endif()
87
88 if(WITH_FREESTYLE)
89         add_definitions(-DWITH_FREESTYLE)
90         blender_include_dirs(../blender/freestyle)
91 endif()
92
93 # Setup the exe sources and buildinfo
94 set(SRC
95         creator.c
96 )
97
98 # MSVC 2010 gives linking errors with the manifest
99 if(WIN32 AND NOT UNIX)
100         string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
101         string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
102         string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
103         if(MINGW)
104                 add_definitions(
105                         -DWINDRES
106                         -DBLEN_VER_RC_STR_M=${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         else()
113                 add_definitions(
114                         -DBLEN_VER_RC_STR=${BLENDER_VERSION}
115                         -DBLEN_VER_RC_1=${bver1}
116                         -DBLEN_VER_RC_2=${bver2}
117                         -DBLEN_VER_RC_3=${bver3}
118                         -DBLEN_VER_RC_4=0
119                 )
120         endif()
121
122
123         list(APPEND SRC
124                 ../icons/winblender.rc
125         )
126 endif()
127
128 if(WITH_BUILDINFO)
129         add_definitions(-DWITH_BUILDINFO)
130         # --------------------------------------------------------------------------
131         # These defines could all be moved into the header below
132         string(REPLACE " " "\ " BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}")
133         string(REPLACE " " "\ " BUILDINFO_CXXFLAGS "${CMAKE_CXX_FLAGS}")
134         string(REPLACE " " "\ " BUILDINFO_LINKFLAGS "${PLATFORM_LINKFLAGS}")
135         add_definitions(
136                 # # define in header now, else these get out of date on rebuilds.
137                 # -DBUILD_DATE="${BUILD_DATE}"
138                 # -DBUILD_TIME="${BUILD_TIME}"
139                 # -DBUILD_COMMIT_TIMESTAMP="${BUILD_COMMIT_TIMESTAMP}"
140                 # -DBUILD_COMMIT_TIME="${BUILD_COMMIT_TIME}"
141                 # -DBUILD_COMMIT_DATE="${BUILD_COMMIT_DATE}"
142                 # -DBUILD_HASH="${BUILD_HASH}"
143                 # -DBUILD_BRANCH="${BUILD_BRANCH}"
144                 -DWITH_BUILDINFO_HEADER # alternative to lines above
145                 -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
146                 -DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
147                 -DBUILD_CFLAGS="${BUILDINFO_CFLAGS}"
148                 -DBUILD_CXXFLAGS="${BUILDINFO_CXXFLAGS}"
149                 -DBUILD_LINKFLAGS="${BUILDINFO_LINKFLAGS}"
150                 -DBUILD_SYSTEM="CMake"
151         )
152
153         # --------------------------------------------------------------------------
154         # write header for values that change each build
155         # note, generaed file is in build dir's source/creator
156         #       except when used as an include path.
157
158         # include the output directory, where the buildinfo.h file is generated
159         include_directories(${CMAKE_BINARY_DIR}/source/creator)
160
161         # a custom target that is always built
162         add_custom_target(buildinfo ALL
163                 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h)
164
165         # creates svnheader.h using cmake script
166         add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h
167                 COMMAND ${CMAKE_COMMAND}
168                 -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
169                 -P ${CMAKE_SOURCE_DIR}/build_files/cmake/buildinfo.cmake)
170
171         # buildinfo.h is a generated file
172         set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h
173                 PROPERTIES GENERATED TRUE
174                 HEADER_FILE_ONLY TRUE)
175
176         # add deps below, after adding blender
177         # -------------- done with header values.
178
179         list(APPEND SRC
180                 buildinfo.c
181         )
182
183         # make an object library so can load with it in tests
184         add_library(buildinfoobj OBJECT buildinfo.c)
185         add_dependencies(buildinfoobj buildinfo)
186 endif()
187
188 # message(STATUS "Configuring blender")
189 if(WITH_PYTHON_MODULE)
190         add_definitions(-DWITH_PYTHON_MODULE)
191
192         # creates ./bin/bpy.so which can be imported as a python module.
193         #
194         # note that 'SHARED' works on Linux and Windows,
195         # but not OSX which _must_ be 'MODULE'
196         add_library(blender MODULE ${SRC})
197         set_target_properties(
198                 blender
199                 PROPERTIES
200                         PREFIX ""
201                         OUTPUT_NAME bpy
202                         LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
203                         RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin  # only needed on windows
204         )
205
206         if(APPLE)
207                 set_target_properties(
208                         blender
209                         PROPERTIES
210                                 LINK_FLAGS_RELEASE "${PLATFORM_LINKFLAGS}"
211                                 LINK_FLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG}"
212                 )
213         endif()
214
215         if(WIN32)
216                 # python modules use this
217                 set_target_properties(
218                         blender
219                         PROPERTIES
220                         SUFFIX ".pyd"
221                 )
222         endif()
223
224 else()
225         add_executable(blender ${EXETYPE} ${SRC})
226 endif()
227
228 if(WITH_BUILDINFO)
229         # explicitly say that the executable depends on the buildinfo
230         add_dependencies(blender buildinfo)
231 endif()
232
233 # Post build steps for bundling/packaging.
234
235
236 if(MSVC_IDE)
237         # ${CMAKE_CFG_INTDIR} should replace \${BUILD_TYPE} when using add_command
238         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE})
239 elseif(APPLE)
240         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE})
241 else()
242         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH})
243 endif()
244
245 set(BLENDER_TEXT_FILES
246         ${CMAKE_SOURCE_DIR}/release/text/GPL-license.txt
247         ${CMAKE_SOURCE_DIR}/release/text/Python-license.txt
248         ${CMAKE_SOURCE_DIR}/release/text/copyright.txt
249         ${CMAKE_SOURCE_DIR}/release/text/readme.html
250         ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-bfont.ttf.txt
251 )
252
253 if(WITH_INTERNATIONAL)
254         list(APPEND BLENDER_TEXT_FILES
255                 ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-droidsans.ttf.txt
256                 ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-bmonofont-i18n.ttf.txt
257         )
258 endif()
259
260
261 # -----------------------------------------------------------------------------
262 # Platform Specific Var: TARGETDIR_VER
263
264 if(UNIX AND NOT APPLE)
265         if(WITH_INSTALL_PORTABLE)
266                 set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
267         else()
268                 if(WITH_PYTHON_MODULE)
269                         set(TARGETDIR_VER ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/${BLENDER_VERSION})
270                 else()
271                         set(TARGETDIR_VER ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION})
272                 endif()
273         endif()
274
275 elseif(WIN32)
276         set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
277
278 elseif(APPLE)
279         if(WITH_PYTHON_MODULE)
280                 set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
281         else()
282                 set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/Resources/${BLENDER_VERSION})
283         endif()
284
285 endif()
286
287
288 # -----------------------------------------------------------------------------
289 # Install Targets (Generic, All Platforms)
290
291
292 # important to make a clean  install each time, else old scripts get loaded.
293 install(
294         CODE
295         "file(REMOVE_RECURSE ${TARGETDIR_VER})"
296 )
297
298 if(WITH_PYTHON)
299         # install(CODE "message(\"copying blender scripts...\")")
300         
301         # exclude addons_contrib if release
302         if("${BLENDER_VERSION_CYCLE}" STREQUAL "release")
303                 set(ADDON_EXCLUDE_CONDITIONAL "addons_contrib/*")
304         else()
305                 set(ADDON_EXCLUDE_CONDITIONAL "_addons_contrib/*")  # dummy, wont do anything
306         endif()
307
308         # do not install freestyle dir if disabled
309         if(NOT WITH_FREESTYLE)
310                 set(FREESTYLE_EXCLUDE_CONDITIONAL "freestyle/*")
311         else()
312                 set(FREESTYLE_EXCLUDE_CONDITIONAL "_freestyle/*")  # dummy, wont do anything
313         endif()
314
315         install(
316                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
317                 DESTINATION ${TARGETDIR_VER}
318                 PATTERN ".git" EXCLUDE
319                 PATTERN "__pycache__" EXCLUDE
320                 PATTERN "${ADDON_EXCLUDE_CONDITIONAL}" EXCLUDE
321                 PATTERN "${FREESTYLE_EXCLUDE_CONDITIONAL}" EXCLUDE
322         )
323         
324         unset(ADDON_EXCLUDE_CONDITIONAL)
325         unset(FREESTYLE_EXCLUDE_CONDITIONAL)
326 endif()
327
328 # localization
329 if(WITH_INTERNATIONAL)
330         install(
331                 DIRECTORY
332                         ${CMAKE_SOURCE_DIR}/release/datafiles/fonts
333                 DESTINATION ${TARGETDIR_VER}/datafiles
334         )
335
336         set(_locale_dir "${CMAKE_SOURCE_DIR}/release/datafiles/locale")
337         set(_locale_target_dir ${TARGETDIR_VER}/datafiles/locale)
338
339         file(GLOB _po_files "${_locale_dir}/po/*.po")
340         foreach(_po_file ${_po_files})
341                 msgfmt_simple(${_po_file} _all_mo_files)
342         endforeach()
343
344         # Create a custom target which will compile all po to mo
345         add_custom_target(
346                 locales
347                 DEPENDS ${_all_mo_files})
348
349         add_dependencies(blender locales)
350
351         # Generate INSTALL rules
352         install(
353                 FILES ${_locale_dir}/languages
354                 DESTINATION ${_locale_target_dir}
355         )
356
357         foreach(_mo_file ${_all_mo_files})
358                 get_filename_component(_locale_name ${_mo_file} NAME_WE)
359                 install(
360                         FILES ${_mo_file}
361                         DESTINATION ${_locale_target_dir}/${_locale_name}/LC_MESSAGES
362                         RENAME blender.mo
363                 )
364                 unset(_locale_name)
365         endforeach()
366
367         unset(_all_mo_files)
368         unset(_po_files)
369         unset(_po_file)
370         unset(_mo_file)
371         unset(_locale_target_dir)
372
373         unset(_locale_dir)
374 endif()
375
376 # color management
377 if(WITH_OPENCOLORIO)
378         install(
379                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/colormanagement
380                 DESTINATION ${TARGETDIR_VER}/datafiles
381         )
382 endif()
383
384 # helpful tip when using make
385 if("${CMAKE_GENERATOR}" MATCHES ".*Makefiles.*")
386         # message after building.
387         add_custom_command(
388                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
389                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files and scripts to ${TARGETDIR_VER}'
390         )
391 endif()
392
393
394 # -----------------------------------------------------------------------------
395 # Install Targets (Platform Specific)
396
397 if(UNIX AND NOT APPLE)
398
399         if(NOT WITH_PYTHON_MODULE)
400                 install(
401                         CODE
402                         "
403                         execute_process(COMMAND
404                                                         ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1.py
405                                                         ${TARGETDIR}/blender
406                                                         ${TARGETDIR}/blender.1)
407                         "
408                 )
409         endif()
410
411         # there are a few differences between portable and system install
412         if(WITH_INSTALL_PORTABLE)
413                 install(
414                         FILES ${TARGETDIR}/blender.1
415                         DESTINATION ${TARGETDIR}
416                 )
417
418                 install(
419                         FILES
420                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
421                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
422                         DESTINATION ${TARGETDIR}
423                 )
424
425                 install(
426                         PROGRAMS
427                         ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
428                         DESTINATION ${TARGETDIR}
429                 )
430
431                 install(
432                         FILES ${BLENDER_TEXT_FILES}
433                         DESTINATION ${TARGETDIR}
434                 )
435
436         else()
437                 # main blender binary
438                 if(WITH_PYTHON_MODULE)
439                         install(
440                                 TARGETS blender
441                                 LIBRARY
442                                 DESTINATION ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages
443                         )
444                 else()
445                         install(
446                                 PROGRAMS ${TARGETDIR}/blender
447                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
448                         )
449                         # manpage only with 'blender' binary
450                         install(
451                                 FILES ${TARGETDIR}/blender.1
452                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
453                         )
454                 endif()
455
456
457                 if(WITH_GAMEENGINE AND WITH_PLAYER)
458                         install(
459                                 PROGRAMS ${TARGETDIR}/blenderplayer
460                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
461                         )
462                 endif()
463
464                 # misc files
465                 install(
466                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
467                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
468                 )
469                 install(
470                         DIRECTORY
471                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/16x16
472                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/22x22
473                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/24x24
474                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/32x32
475                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48
476                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256
477                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor
478                         PATTERN "*.svg" EXCLUDE
479                 )
480                 install(
481                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
482                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps
483                 )
484                 install(
485                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
486                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
487                 )
488                 install(
489                         FILES ${BLENDER_TEXT_FILES}
490                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
491                 )
492         endif()
493
494         if(WITH_PYTHON)
495                 if(WITH_PYTHON_INSTALL)
496                         # on some platforms (like openSUSE) Python is linked
497                         # to be used from lib64 folder.
498                         # determine this from Python's libraries path
499                         #
500                         # ugh, its possible 'lib64' is just a symlink to 'lib' which causes incorrect use of 'lib64'
501                         get_filename_component(_pypath_real ${PYTHON_LIBPATH} REALPATH)
502                         if(${_pypath_real} MATCHES "lib64$")
503                                 set(_target_LIB "lib64")
504                         else()
505                                 set(_target_LIB "lib")
506                         endif()
507                         unset(_pypath_real)
508
509                         # Copy the systems python into the install directory
510                         # Scons copy in tools/Blender.py
511                         # install(CODE "message(\"copying a subset of the systems python...\")")
512                         install(
513                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
514                                 DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}
515                                 PATTERN ".svn" EXCLUDE
516                                 PATTERN "__pycache__" EXCLUDE               # * any cache *
517                                 PATTERN "distutils" EXCLUDE                 # ./distutils
518                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
519                                 PATTERN "config" EXCLUDE                    # ./config
520                                 PATTERN "config-*" EXCLUDE                  # ./config-*
521                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
522                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
523                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
524                                 PATTERN "idlelib" EXCLUDE                   # ./idlelib
525                                 PATTERN "test" EXCLUDE                      # ./test
526                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
527                                 PATTERN "turtle.py" EXCLUDE                 # ./turtle.py
528                         )
529
530                         # # doesnt work, todo
531                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
532
533                         if(WITH_PYTHON_INSTALL_NUMPY)
534                                 # Install to the same directory as the source, so debian-like
535                                 # distros are happy with their policy.
536                                 set(_suffix "site-packages")
537                                 if(${PYTHON_NUMPY_PATH} MATCHES "dist-packages")
538                                         set(_suffix "dist-packages")
539                                 endif()
540                                 install(
541                                         DIRECTORY ${PYTHON_NUMPY_PATH}/numpy
542                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
543                                         PATTERN ".svn" EXCLUDE
544                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
545                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
546                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
547                                         PATTERN "distutils" EXCLUDE             # ./distutils
548                                         PATTERN "oldnumeric" EXCLUDE            # ./oldnumeric
549                                         PATTERN "doc" EXCLUDE                   # ./doc
550                                         PATTERN "tests" EXCLUDE                 # ./tests
551                                         PATTERN "f2py" EXCLUDE                  # ./f2py - fortran/python interface code, not fun for blender devs.
552                                         PATTERN "include" EXCLUDE               # include dirs all over, we wont use NumPy/CAPI
553                                         PATTERN "*.h" EXCLUDE                   # some includes are not in include dirs
554                                         PATTERN "*.a" EXCLUDE                   # ./core/lib/libnpymath.a - for linking, we dont need.
555                                 )
556                                 unset(_suffix)
557                         endif()
558
559                         # Copy requests, we need to generalize site-packages
560                         if(WITH_PYTHON_INSTALL_REQUESTS)
561                                 set(_suffix "site-packages")
562                                 if(${PYTHON_REQUESTS_PATH} MATCHES "dist-packages")
563                                         set(_suffix "dist-packages")
564                                 endif()
565                                 install(
566                                         DIRECTORY ${PYTHON_REQUESTS_PATH}/requests
567                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
568                                         PATTERN ".svn" EXCLUDE
569                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
570                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
571                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
572                                         PATTERN "cacert.pem" EXCLUDE            # for now we don't deal with security
573                                 )
574                                 # On some platforms requests does have extra dependencies.
575                                 set(_requests_deps "chardet" "urllib3")
576                                 foreach(_requests_dep ${_requests_deps})
577                                         if(EXISTS ${PYTHON_REQUESTS_PATH}/${_requests_dep})
578                                                 install(
579                                                         DIRECTORY ${PYTHON_REQUESTS_PATH}/${_requests_dep}
580                                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
581                                                         PATTERN ".svn" EXCLUDE
582                                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
583                                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
584                                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
585                                                 )
586                                         endif()
587                                 endforeach()
588                                 if(EXISTS ${PYTHON_REQUESTS_PATH}/six.py)
589                                         install(
590                                                 FILES ${PYTHON_REQUESTS_PATH}/six.py
591                                                 DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
592                                         )
593                                         endif()
594                                 unset(_requests_dep)
595                                 unset(_requests_deps)
596                                 unset(_suffix)
597                         endif()
598                         unset(_target_LIB)
599                         
600                 endif()
601         endif()
602 elseif(WIN32)
603
604         install(
605                 FILES ${BLENDER_TEXT_FILES}
606                 DESTINATION ${TARGETDIR}
607         )
608
609         if(WITH_PYTHON)
610                 string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
611
612                 install(
613                         FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.dll ${LIBDIR}/python/lib/sqlite3.dll
614                         DESTINATION ${TARGETDIR}
615                         CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
616                 )
617
618                 install(
619                         FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll ${LIBDIR}/python/lib/sqlite3_d.dll
620                         DESTINATION ${TARGETDIR}
621                         CONFIGURATIONS Debug
622                 )
623
624                 if(WITH_PYTHON_INSTALL)
625                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
626
627                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
628                         install(
629                                 CODE
630                                 "
631                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
632                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\")
633                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\")
634                                 message(\"done creating dir\")
635                                 "
636                         )
637
638                         install(
639                                 CODE
640                                 "
641                                 if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
642                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
643                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_d.tar.gz\")
644                                 else()
645                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
646                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}.tar.gz\")
647                                 endif()
648                                 "
649                         )
650
651                         if(WITH_PYTHON_INSTALL_NUMPY)
652                                 install(
653                                         CODE
654                                         "
655                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/site-packages\"
656                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_1.8.tar.gz\")
657                                         "
658                                 )
659                         endif()
660
661                         # release/site-packages
662                         install(
663                                 CODE
664                                 "
665                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E copy_directory
666                                         ${LIBDIR}/release/site-packages
667                                         \"${TARGETDIR_VER}/python/lib/site-packages\")
668                                 "
669                         )
670
671
672                         # doesnt work, todo
673                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
674                 endif()
675
676                 unset(_PYTHON_VERSION_NO_DOTS)
677         endif()
678
679         if(MSVC)
680                 install(
681                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
682                         DESTINATION ${TARGETDIR}
683                 )
684         else()
685                 #MinGW64 comes with own version. For portable builds it will probaly have to be copied to work
686                 if(NOT WITH_MINGW64)
687                         install(
688                                 FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
689                                 DESTINATION ${TARGETDIR}
690                         )
691                 elseif(WITH_MINGW64)
692                         install(
693                                 FILES 
694                                         ${LIBDIR}/binaries/libgcc_s_sjlj-1.dll
695                                         ${LIBDIR}/binaries/libwinpthread-1.dll
696                                         ${LIBDIR}/binaries/libstdc++-6.dll
697                                 DESTINATION ${TARGETDIR}
698                         )
699                         
700                         if(WITH_OPENMP)
701                                 install(
702                                         FILES 
703                                         ${LIBDIR}/binaries/libgomp-1.dll
704                                         DESTINATION ${TARGETDIR}
705                                 )
706                         endif()
707                 endif()
708         endif()
709
710         if(WITH_CODEC_FFMPEG)
711                 if(WITH_MINGW64)
712                         install(
713                                 FILES
714                                         ${LIBDIR}/ffmpeg/lib/avcodec-53.dll
715                                         ${LIBDIR}/ffmpeg/lib/avformat-53.dll
716                                         ${LIBDIR}/ffmpeg/lib/avdevice-53.dll
717                                         ${LIBDIR}/ffmpeg/lib/avutil-51.dll
718                                         ${LIBDIR}/ffmpeg/lib/swscale-2.dll
719                                         ${LIBDIR}/ffmpeg/lib/swresample-0.dll
720                                         ${LIBDIR}/ffmpeg/lib/xvidcore.dll
721                                 DESTINATION ${TARGETDIR}
722                         )
723                 else()
724                         install(
725                                 FILES
726                                         ${LIBDIR}/ffmpeg/lib/avcodec-55.dll
727                                         ${LIBDIR}/ffmpeg/lib/avformat-55.dll
728                                         ${LIBDIR}/ffmpeg/lib/avdevice-55.dll
729                                         ${LIBDIR}/ffmpeg/lib/avutil-52.dll
730                                         ${LIBDIR}/ffmpeg/lib/swscale-2.dll
731                                 DESTINATION ${TARGETDIR}
732                         )
733                 endif()
734         endif()
735
736         if(WITH_CODEC_SNDFILE)
737                 install(
738                         FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
739                         DESTINATION ${TARGETDIR}
740                 )
741         endif()
742
743         if(WITH_OPENAL)
744                 install(
745                         FILES
746                                 ${LIBDIR}/openal/lib/OpenAL32.dll
747                                 ${LIBDIR}/openal/lib/wrap_oal.dll
748                         DESTINATION ${TARGETDIR}
749                 )
750         endif()
751
752         if(WITH_SDL)
753                 install(
754                         FILES ${LIBDIR}/sdl/lib/SDL.dll
755                         DESTINATION ${TARGETDIR}
756                 )
757         endif()
758
759         if(NOT CMAKE_CL_64)
760                 install(
761                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
762                         DESTINATION ${TARGETDIR}
763                 )
764         endif()
765                 
766         install( # x86 builds can run on x64 Windows, so this is required at all times
767                 FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
768                 DESTINATION ${TARGETDIR}
769         )
770
771         if(WITH_OPENCOLORIO)
772                 set(OCIOBIN ${LIBDIR}/opencolorio/bin)
773                 if(NOT MINGW)
774                         install(
775                                 FILES
776                                         ${OCIOBIN}/OpenColorIO.dll
777                                 DESTINATION ${TARGETDIR}
778                         )
779                 else()
780                         install(
781                                 FILES
782                                         ${OCIOBIN}/libOpenColorIO.dll
783                                 DESTINATION ${TARGETDIR}
784                         )
785                 endif()
786         endif()
787
788 elseif(APPLE)
789
790         # handy install macro to exclude files, we use \$ escape for the "to"
791         # argument when calling so ${BUILD_TYPE} does not get expanded
792         macro(install_dir from to)
793                 install(
794                         DIRECTORY ${from}
795                         DESTINATION ${to}
796                         PATTERN ".git" EXCLUDE
797                         PATTERN ".svn" EXCLUDE
798                         PATTERN "*.pyc" EXCLUDE
799                         PATTERN "*.pyo" EXCLUDE
800                         PATTERN "*.orig" EXCLUDE
801                         PATTERN "*.rej" EXCLUDE
802                         PATTERN "__pycache__" EXCLUDE
803                         PATTERN "__MACOSX" EXCLUDE
804                         PATTERN ".DS_Store" EXCLUDE
805                 )
806         endmacro()
807
808         set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blender.app)
809
810         # setup Info.plist
811         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
812
813         set_target_properties(blender PROPERTIES
814                 MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist
815                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
816                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
817
818
819         # install release and app files
820         install(
821                 FILES ${BLENDER_TEXT_FILES}
822                 DESTINATION ${TARGETDIR}
823         )
824
825         install(
826                 FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo
827                 DESTINATION ${TARGETDIR}/blender.app/Contents
828         )
829
830         install_dir(
831                 ${OSX_APP_SOURCEDIR}/Contents/Resources
832                 \${TARGETDIR}/blender.app/Contents/
833         )
834
835         if(WITH_OPENMP AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT ${CMAKE_C_COMPILER_VERSION} VERSION_LESS '3.4')
836                 install(
837                         FILES ${LIBDIR}/openmp/lib/libiomp5.dylib
838                         DESTINATION ${TARGETDIR}/blender.app/Contents/MacOS
839                 )
840         endif()
841
842         if(WITH_LLVM AND NOT LLVM_STATIC)
843                 install(
844                         FILES ${LIBDIR}/llvm/lib/libLLVM-3.4.dylib
845                         DESTINATION ${TARGETDIR}/blender.app/Contents/MacOS
846                 )
847         endif()
848
849         # python
850         if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
851                 # the python zip is first extract as part of the build process,
852                 # and then later installed as part of make install. this is much
853                 # quicker, and means we can easily exclude files on copy
854                 # Not needed for PYTHON_MODULE or WEB_PLUGIN due uses  Pyhon framework
855                 add_custom_target(
856                         extractpyzip
857                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
858
859                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
860
861                 add_custom_command(
862                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
863                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
864                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
865                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
866                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
867
868                 add_dependencies(blender extractpyzip)
869
870                 # copy extracted python files
871                 install_dir(
872                         ${CMAKE_CURRENT_BINARY_DIR}/python
873                         \${TARGETDIR_VER}
874                 )
875                 # copy site-packages files
876                 install_dir(
877                         ${LIBDIR}/release/site-packages
878                         ${CMAKE_CURRENT_BINARY_DIR}/python/lib/python${PYTHON_VERSION}/site-packages
879                 )
880
881         endif()
882         
883         # install blenderplayer bundle - copy of blender.app above. re-using macros et al
884         # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
885         if(WITH_GAMEENGINE AND WITH_PLAYER)
886                 set(OSX_APP_PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blenderplayer.app)
887                 set(PLAYER_SOURCEINFO ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Info.plist)
888                 set(PLAYER_TARGETDIR_VER ${TARGETDIR}/blenderplayer.app/Contents/MacOS/${BLENDER_VERSION})
889
890
891                 # important to make a clean  install each time else old scripts get loaded.
892                 install(
893                         CODE
894                         "file(REMOVE_RECURSE ${PLAYER_TARGETDIR_VER})"
895                 )
896
897                 install(
898                         FILES ${OSX_APP_PLAYER_SOURCEDIR}/Contents/PkgInfo
899                         DESTINATION ${TARGETDIR}/blenderplayer.app/Contents
900                 )
901
902                 install_dir(
903                         ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Resources
904                         \${TARGETDIR}/blenderplayer.app/Contents/
905                 )
906
907                 # python
908                 if(WITH_PYTHON AND NOT WITH_PYTHON_FRAMEWORK)
909                         add_custom_command(
910                                 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
911                                 COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
912                                 COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
913                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
914                                 DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
915
916                         # copy extracted python files
917                         install_dir(
918                                 ${CMAKE_CURRENT_BINARY_DIR}/python
919                                 \${PLAYER_TARGETDIR_VER}
920                         )
921                 endif()
922
923         endif()
924
925 endif()
926
927 # -----------------------------------------------------------------------------
928 # Generic Install, for all targets
929
930
931
932 # install more files specified elsewhere
933 delayed_do_install(${TARGETDIR_VER})
934
935 unset(BLENDER_TEXT_FILES)
936
937
938 # -----------------------------------------------------------------------------
939 # Setup link libs
940
941 add_dependencies(blender makesdna)
942
943 setup_blender_sorted_libs()
944
945 target_link_libraries(blender ${BLENDER_SORTED_LIBS})
946
947 setup_liblinks(blender)
948
949 # -----------------------------------------------------------------------------
950 # Setup launcher
951
952 if(WIN32 AND NOT WITH_PYTHON_MODULE)
953         set(LAUNCHER_SRC
954                 creator_launch_win.c
955                 ../icons/winblender.rc
956         )
957         add_executable(blender-launcher ${LAUNCHER_SRC})
958         target_link_libraries(blender-launcher bf_intern_utfconv ${PLATFORM_LINKLIBS})
959
960         set_target_properties(blender PROPERTIES OUTPUT_NAME blender-app)
961         set_target_properties(blender-launcher PROPERTIES OUTPUT_NAME blender)
962 endif()