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