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