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