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