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