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