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