Cleanup: remove contributors for CMake files
[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                         DESTINATION "."
478                 )
479
480                 install(
481                         PROGRAMS
482                         ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
483                         DESTINATION "."
484                 )
485
486                 set(BLENDER_TEXT_FILES_DESTINATION ".")
487         else()
488                 # main blender binary
489                 install(
490                         TARGETS blender
491                         DESTINATION bin
492                 )
493                 if(WITH_DOC_MANPAGE)
494                         # manpage only with 'blender' binary
495                         install(
496                                 FILES ${CMAKE_CURRENT_BINARY_DIR}/blender.1
497                                 DESTINATION share/man/man1
498                         )
499                 endif()
500
501                 # misc files
502                 install(
503                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
504                         DESTINATION share/applications
505                 )
506                 install(
507                         DIRECTORY
508                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/16x16
509                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/22x22
510                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/24x24
511                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/32x32
512                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48
513                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256
514                         DESTINATION share/icons/hicolor
515                         PATTERN "*.svg" EXCLUDE
516                 )
517                 install(
518                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
519                         DESTINATION share/icons/hicolor/scalable/apps
520                 )
521                 install(
522                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
523                         DESTINATION bin
524                 )
525                 set(BLENDER_TEXT_FILES_DESTINATION share/doc/blender)
526         endif()
527
528         if(WITH_PYTHON)
529                 if(WITH_PYTHON_INSTALL)
530
531                         install(
532                                 PROGRAMS ${PYTHON_EXECUTABLE}
533                                 DESTINATION ${TARGETDIR_VER}/python/bin
534                         )
535
536                         # on some platforms (like openSUSE) Python is linked
537                         # to be used from lib64 folder.
538                         # determine this from Python's libraries path
539                         #
540                         # ugh, its possible 'lib64' is just a symlink to 'lib' which causes incorrect use of 'lib64'
541                         get_filename_component(_pypath_real ${PYTHON_LIBPATH} REALPATH)
542                         if(${_pypath_real} MATCHES "lib64$")
543                                 set(_target_LIB "lib64")
544                         else()
545                                 set(_target_LIB "lib")
546                         endif()
547                         unset(_pypath_real)
548
549                         # Copy the systems python into the install directory
550                         # install(CODE "message(\"copying a subset of the systems python...\")")
551                         install(
552                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
553                                 DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}
554                                 PATTERN "__pycache__" EXCLUDE               # * any cache *
555                                 PATTERN "config-${PYTHON_VERSION}m/*.a" EXCLUDE  # static lib
556                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
557                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
558                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
559                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
560                                 PATTERN "idlelib" EXCLUDE                   # ./idlelib
561                                 PATTERN "test" EXCLUDE                      # ./test
562                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
563                                 PATTERN "turtle.py" EXCLUDE                 # ./turtle.py
564                         )
565
566                         # Needed for distutils/pip
567                         # get the last part of the include dir, will be 'python{version}{abiflag}',
568                         get_filename_component(_py_inc_suffix ${PYTHON_INCLUDE_DIR} NAME)
569                         install(
570                                 FILES ${PYTHON_INCLUDE_DIR}/pyconfig.h
571                                 DESTINATION ${TARGETDIR_VER}/python/include/${_py_inc_suffix}
572                         )
573                         unset(_py_inc_suffix)
574
575                         if(WITH_PYTHON_INSTALL_NUMPY)
576                                 # Install to the same directory as the source, so debian-like
577                                 # distros are happy with their policy.
578                                 set(_suffix "site-packages")
579                                 if(${PYTHON_NUMPY_PATH} MATCHES "dist-packages")
580                                         set(_suffix "dist-packages")
581                                 endif()
582                                 install(
583                                         DIRECTORY ${PYTHON_NUMPY_PATH}/numpy
584                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
585                                         PATTERN ".svn" EXCLUDE
586                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
587                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
588                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
589                                         PATTERN "oldnumeric" EXCLUDE            # ./oldnumeric
590                                         PATTERN "doc" EXCLUDE                   # ./doc
591                                         PATTERN "tests" EXCLUDE                 # ./tests
592                                         PATTERN "f2py" EXCLUDE                  # ./f2py - fortran/python interface code, not for blender.
593                                         PATTERN "include" EXCLUDE               # include dirs all over, we wont use NumPy/CAPI
594                                         PATTERN "*.h" EXCLUDE                   # some includes are not in include dirs
595                                         PATTERN "*.a" EXCLUDE                   # ./core/lib/libnpymath.a - for linking, we dont need.
596                                 )
597                                 unset(_suffix)
598                         endif()
599
600                         # Copy requests, we need to generalize site-packages
601                         if(WITH_PYTHON_INSTALL_REQUESTS)
602                                 set(_suffix "site-packages")
603                                 if(${PYTHON_REQUESTS_PATH} MATCHES "dist-packages")
604                                         set(_suffix "dist-packages")
605                                 endif()
606                                 install(
607                                         DIRECTORY ${PYTHON_REQUESTS_PATH}/requests
608                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
609                                         PATTERN ".svn" EXCLUDE
610                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
611                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
612                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
613                                 )
614                                 # On some platforms requests does have extra dependencies.
615                                 set(_requests_deps "certifi" "chardet" "idna" "urllib3")
616                                 foreach(_requests_dep ${_requests_deps})
617                                         if(EXISTS ${PYTHON_REQUESTS_PATH}/${_requests_dep})
618                                                 install(
619                                                         DIRECTORY ${PYTHON_REQUESTS_PATH}/${_requests_dep}
620                                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
621                                                         PATTERN ".svn" EXCLUDE
622                                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
623                                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
624                                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
625                                                 )
626                                         endif()
627                                 endforeach()
628                                 if(EXISTS ${PYTHON_REQUESTS_PATH}/six.py)
629                                         install(
630                                                 FILES ${PYTHON_REQUESTS_PATH}/six.py
631                                                 DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
632                                         )
633                                 endif()
634                                 unset(_requests_dep)
635                                 unset(_requests_deps)
636                                 unset(_suffix)
637                         endif()
638                         unset(_target_LIB)
639
640                 endif()
641         endif()
642 elseif(WIN32)
643
644         set(BLENDER_TEXT_FILES_DESTINATION ".")
645
646         if(WITH_PYTHON)
647                 string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
648
649                 if(NOT CMAKE_COMPILER_IS_GNUCC)
650                         install(
651                                 FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.dll
652                                 DESTINATION "."
653                                 CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
654                         )
655
656                         install(
657                                 FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll
658                                 DESTINATION "."
659                                 CONFIGURATIONS Debug
660                         )
661                 endif()
662
663                 if(WITH_PYTHON_INSTALL)
664                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
665
666                         install(DIRECTORY DESTINATION ${TARGETDIR_VER}/python)
667                         install(DIRECTORY DESTINATION ${TARGETDIR_VER}/python/lib)
668
669                         # WARNING: its important that 'CMAKE_INSTALL_CONFIG_NAME' is evaluated at build time
670                         # and _NOT_ configuration time, when modifying the lines below,
671                         # check it works in both Release & Debug mode.
672                         #
673                         # Edit with extreme care! - Campbell
674
675                         # extract python
676                         install(
677                                 CODE
678                                 "
679                                 message(STATUS \"Extracting Python to: \${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/python\")
680                                 if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Dd][Ee][Bb][Uu][Gg])$\")
681                                         set(PYTHON_ZIP \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_d.tar.gz\")
682                                 else()
683                                         set(PYTHON_ZIP \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}.tar.gz\")
684                                 endif()
685
686                                 execute_process(
687                                         COMMAND \${CMAKE_COMMAND} -E make_directory
688                                                 \"\${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/python\"
689                                         COMMAND \${CMAKE_COMMAND} -E
690                                                 chdir \"\${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/python\"
691                                                 \${CMAKE_COMMAND} -E
692                                                 tar xzfv \"\${PYTHON_ZIP}\"
693                                 )
694                                 unset(PYTHON_ZIP)
695                                 "
696                         )
697
698                         # release/site-packages
699                         install(
700                                 DIRECTORY ${LIBDIR}/release/site-packages
701                                 DESTINATION ${BLENDER_VERSION}/python/lib
702                                 PATTERN ".svn" EXCLUDE
703                                 PATTERN "__pycache__" EXCLUDE           # * any cache *
704                                 PATTERN "*.pyc" EXCLUDE                 # * any cache *
705                                 PATTERN "*.pyo" EXCLUDE                 # * any cache *)
706                         )
707
708                         if(WITH_PYTHON_INSTALL_NUMPY)
709                                 set(PYTHON_NUMPY_VERSION 1.15)
710                                 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages
711                                         COMMAND ${CMAKE_COMMAND} -E
712                                                 make_directory ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages)
713
714                                 add_custom_command(
715                                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy
716                                         COMMAND ${CMAKE_COMMAND} -E
717                                                 tar xzvf "${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_${PYTHON_NUMPY_VERSION}$<$<CONFIG:Debug>:d>.tar.gz"
718                                         DEPENDS
719                                                 ${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_${PYTHON_NUMPY_VERSION}$<$<CONFIG:Debug>:d>.tar.gz
720                                                 ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages
721                                         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages
722                                 )
723                                 add_custom_target(
724                                         python_numpy ALL
725                                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy
726                                 )
727                                 install(
728                                         DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy
729                                         DESTINATION ${BLENDER_VERSION}/python/lib/site-packages
730                                 )
731                         endif()
732
733
734                         # TODO(sergey): For unti we've got better way to deal with python binary
735                         install(
736                                 FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.dll
737                                 DESTINATION ${BLENDER_VERSION}/python/bin
738                                 CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
739                         )
740                         install(
741                                 FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll
742                                 DESTINATION ${BLENDER_VERSION}/python/bin
743                                 CONFIGURATIONS Debug
744                         )
745                         if(WINDOWS_PYTHON_DEBUG)
746                                 install(
747                                         FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.pdb
748                                         DESTINATION "."
749                                         CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
750                                 )
751
752                                 install(
753                                         FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.pdb
754                                         DESTINATION "."
755                                         CONFIGURATIONS Debug
756                                 )
757                         endif()
758                 endif()
759
760                 unset(_PYTHON_VERSION_NO_DOTS)
761         endif()
762
763         # EGL Runtime Components
764         if(WITH_GL_EGL)
765                 if(WIN32)
766                         install(FILES "${OPENGLES_DLL}"     DESTINATION ".")
767                         install(FILES "${OPENGLES_EGL_DLL}" DESTINATION ".")
768
769                         if(WITH_GL_ANGLE)
770                                 install(FILES "${D3DCOMPILER_DLL}" DESTINATION ".")
771                         endif()
772                 endif()
773         endif()
774
775         if(MSVC)
776                 install(
777                         FILES ${LIBDIR}/pthreads/lib/pthreadVC3.dll
778                         DESTINATION "."
779                 )
780         endif()
781
782         if(WITH_CODEC_FFMPEG)
783                 install(
784                         FILES
785                                 ${LIBDIR}/ffmpeg/lib/avcodec-58.dll
786                                 ${LIBDIR}/ffmpeg/lib/avformat-58.dll
787                                 ${LIBDIR}/ffmpeg/lib/avdevice-58.dll
788                                 ${LIBDIR}/ffmpeg/lib/avutil-56.dll
789                                 ${LIBDIR}/ffmpeg/lib/swscale-5.dll
790                                 ${LIBDIR}/ffmpeg/lib/swresample-3.dll
791                         DESTINATION "."
792                 )
793         endif()
794
795         if(WITH_CODEC_SNDFILE)
796                 install(
797                         FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
798                         DESTINATION "."
799                 )
800         endif()
801
802         if(WITH_OPENAL)
803                 install(
804                         FILES
805                                 ${LIBDIR}/openal/lib/OpenAL32.dll
806                         DESTINATION "."
807                 )
808         endif()
809
810         if(WITH_SDL)
811                 install(
812                         FILES ${LIBDIR}/sdl/lib/SDL2.dll
813                         DESTINATION "."
814                 )
815         endif()
816
817         if(WITH_SYSTEM_AUDASPACE)
818                 install(
819                         FILES
820                                 ${LIBDIR}/audaspace/lib/audaspace.dll
821                                 ${LIBDIR}/audaspace/lib/audaspace-c.dll
822                                 ${LIBDIR}/audaspace/lib/audaspace-py.dll
823                         DESTINATION "."
824                 )
825         endif()
826
827         if(NOT CMAKE_CL_64)
828                 install(
829                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
830                         DESTINATION "."
831                 )
832         endif()
833
834         install( # x86 builds can run on x64 Windows, so this is required at all times
835                 FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
836                 DESTINATION "."
837         )
838
839 elseif(APPLE)
840
841         # handy install macro to exclude files, we use \$ escape for the "to"
842         # argument when calling so ${BUILD_TYPE} does not get expanded
843         macro(install_dir from to)
844                 install(
845                         DIRECTORY ${from}
846                         DESTINATION ${to}
847                         PATTERN ".git" EXCLUDE
848                         PATTERN ".svn" EXCLUDE
849                         PATTERN "*.pyc" EXCLUDE
850                         PATTERN "*.pyo" EXCLUDE
851                         PATTERN "*.orig" EXCLUDE
852                         PATTERN "*.rej" EXCLUDE
853                         PATTERN "__pycache__" EXCLUDE
854                         PATTERN "__MACOSX" EXCLUDE
855                         PATTERN ".DS_Store" EXCLUDE
856                         PATTERN "config-${PYTHON_VERSION}m/*.a" EXCLUDE  # static lib
857                         PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
858                         PATTERN "tkinter" EXCLUDE                   # ./tkinter
859                         PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
860                         PATTERN "idlelib" EXCLUDE                   # ./idlelib
861                         PATTERN "test" EXCLUDE                      # ./test
862                         PATTERN "turtledemo" EXCLUDE                # ./turtledemo
863                         PATTERN "turtle.py" EXCLUDE                 # ./turtle.py
864                 )
865         endmacro()
866
867         set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blender.app)
868
869         # setup Info.plist
870         execute_process(COMMAND date "+%Y-%m-%d"
871                         OUTPUT_VARIABLE BLENDER_DATE
872                         OUTPUT_STRIP_TRAILING_WHITESPACE)
873
874         set_target_properties(blender PROPERTIES
875                 MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist
876                 MACOSX_BUNDLE_SHORT_VERSION_STRING "${BLENDER_VERSION}${BLENDER_VERSION_CHAR}"
877                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION}${BLENDER_VERSION_CHAR} ${BLENDER_DATE}")
878
879         # Gather the date in finder-style
880         execute_process(COMMAND date "+%m/%d/%Y/%H:%M"
881         OUTPUT_VARIABLE SETFILE_DATE
882         OUTPUT_STRIP_TRAILING_WHITESPACE)
883
884         # Give the bundle actual creation/modification date
885         execute_process(COMMAND SetFile -d ${SETFILE_DATE} -m ${SETFILE_DATE}
886                         ${EXECUTABLE_OUTPUT_PATH}/blender.app)
887
888         install(
889                 TARGETS blender
890                 DESTINATION "."
891         )
892
893         # install release and app files
894         set(BLENDER_TEXT_FILES_DESTINATION ".")
895
896         install(
897                 FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo
898                 DESTINATION blender.app/Contents
899         )
900
901         install_dir(
902                 ${OSX_APP_SOURCEDIR}/Contents/Resources
903                 blender.app/Contents/
904         )
905
906         if(WITH_OPENMP AND OPENMP_CUSTOM)
907                 install(
908                         FILES ${LIBDIR}/openmp/lib/libomp.dylib
909                         DESTINATION blender.app/Contents/Resources/lib
910                 )
911         endif()
912
913         if(WITH_LLVM AND NOT LLVM_STATIC)
914                 install(
915                         FILES ${LIBDIR}/llvm/lib/libLLVM-3.4.dylib
916                         DESTINATION blender.app/Contents/MacOS
917                 )
918         endif()
919
920         # python
921         if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
922                 # Copy the python libs into the install directory
923                 install_dir(
924                         ${PYTHON_LIBPATH}
925                         ${TARGETDIR_VER}/python/lib
926                 )
927
928                 install(DIRECTORY ${LIBDIR}/python/bin
929                         DESTINATION ${TARGETDIR_VER}/python
930                         USE_SOURCE_PERMISSIONS
931                 )
932
933                 # Needed for distutils/pip
934                 # get the last part of the include dir, will be 'python{version}{abiflag}',
935                 get_filename_component(_py_inc_suffix ${PYTHON_INCLUDE_DIR} NAME)
936                 install(
937                         FILES ${PYTHON_INCLUDE_DIR}/pyconfig.h
938                         DESTINATION ${TARGETDIR_VER}/python/include/${_py_inc_suffix}
939                 )
940                 unset(_py_inc_suffix)
941         endif()
942
943 endif()
944
945 # -----------------------------------------------------------------------------
946 # Generic Install, for all targets
947
948 if(DEFINED BLENDER_TEXT_FILES_DESTINATION)
949
950         install(
951                 CODE
952                 "
953                 file(READ \"${CMAKE_SOURCE_DIR}/release/text/readme.html\" DATA_SRC)
954                 string(REGEX REPLACE \"BLENDER_VERSION\" \"${BLENDER_VERSION}\" DATA_DST \"\${DATA_SRC}\")
955                 file(WRITE \"${CMAKE_BINARY_DIR}/release/text/readme.html\" \"\${DATA_DST}\")
956                 unset(DATA_SRC)
957                 unset(DATA_DST)
958                 "
959         )
960         list(APPEND BLENDER_TEXT_FILES
961                 ${CMAKE_BINARY_DIR}/release/text/readme.html
962         )
963
964         install(
965                 FILES ${BLENDER_TEXT_FILES}
966                 DESTINATION "${BLENDER_TEXT_FILES_DESTINATION}"
967         )
968 endif()
969
970 # install more files specified elsewhere
971 delayed_do_install(${TARGETDIR_VER})
972
973 unset(BLENDER_TEXT_FILES)
974 unset(BLENDER_TEXT_FILES_DESTINATION)
975
976
977 # -----------------------------------------------------------------------------
978 # Geometry Icons
979
980 # Geometry icons.
981 get_property(_icon_names GLOBAL PROPERTY ICON_GEOM_NAMES)
982 set(_icon_files)
983 foreach(_f ${_icon_names})
984         list(APPEND _icon_files
985                 "${CMAKE_SOURCE_DIR}/release/datafiles/icons/${_f}.dat"
986         )
987 endforeach()
988 install(
989         FILES ${_icon_files}
990         DESTINATION ${TARGETDIR_VER}/datafiles/icons
991 )
992
993 unset(_icon_names)
994 unset(_icon_files)
995 unset(_f)
996
997 # -----------------------------------------------------------------------------
998 # Studio Lights
999 install(
1000         DIRECTORY
1001                 ${CMAKE_SOURCE_DIR}/release/datafiles/studiolights
1002         DESTINATION ${TARGETDIR_VER}/datafiles
1003 )
1004
1005 # -----------------------------------------------------------------------------
1006 # Setup link libs
1007
1008 add_dependencies(blender makesdna)
1009
1010 setup_blender_sorted_libs()
1011 target_link_libraries(blender ${BLENDER_SORTED_LIBS})
1012
1013 setup_liblinks(blender)
1014
1015 # -----------------------------------------------------------------------------
1016 # Setup launcher
1017
1018 if(WIN32 AND NOT WITH_PYTHON_MODULE)
1019         install(
1020                 TARGETS blender
1021                 COMPONENT Blender
1022                 DESTINATION "."
1023         )
1024         set_target_properties(
1025                 blender
1026                 PROPERTIES
1027                         VS_USER_PROPS "blender.Cpp.user.props"
1028         )
1029 endif()