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