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