OSX: make some more symbols global only, this may prevent clashes on older systems...
[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         if(NOT WITH_PYTHON_MODULE)
395                 install(
396                         CODE
397                         "
398                         execute_process(COMMAND
399                                                         ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1.py
400                                                         ${TARGETDIR}/blender
401                                                         ${TARGETDIR}/blender.1)
402                         "
403                 )
404         endif()
405
406         # there are a few differences between portable and system install
407         if(WITH_INSTALL_PORTABLE)
408                 install(
409                         FILES ${TARGETDIR}/blender.1
410                         DESTINATION ${TARGETDIR}
411                 )
412
413                 install(
414                         FILES
415                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
416                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
417                         DESTINATION ${TARGETDIR}
418                 )
419
420                 install(
421                         PROGRAMS
422                         ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
423                         DESTINATION ${TARGETDIR}
424                 )
425
426                 install(
427                         FILES ${BLENDER_TEXT_FILES}
428                         DESTINATION ${TARGETDIR}
429                 )
430
431         else()
432                 # main blender binary
433                 if(WITH_PYTHON_MODULE)
434                         install(
435                                 TARGETS blender
436                                 LIBRARY
437                                 DESTINATION ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages
438                         )
439                 else()
440                         install(
441                                 PROGRAMS ${TARGETDIR}/blender
442                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
443                         )
444                         # manpage only with 'blender' binary
445                         install(
446                                 FILES ${TARGETDIR}/blender.1
447                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
448                         )
449                 endif()
450
451
452                 if(WITH_GAMEENGINE AND WITH_PLAYER)
453                         install(
454                                 PROGRAMS ${TARGETDIR}/blenderplayer
455                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
456                         )
457                 endif()
458
459                 # misc files
460                 install(
461                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
462                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
463                 )
464                 install(
465                         DIRECTORY
466                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/16x16
467                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/22x22
468                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/24x24
469                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/32x32
470                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48
471                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256
472                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor
473                         PATTERN "*.svg" EXCLUDE
474                 )
475                 install(
476                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
477                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps
478                 )
479                 install(
480                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
481                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
482                 )
483                 install(
484                         FILES ${BLENDER_TEXT_FILES}
485                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
486                 )
487         endif()
488
489         if(WITH_PYTHON)
490                 if(WITH_PYTHON_INSTALL)
491                         # on some platforms (like openSUSE) Python is linked
492                         # to be used from lib64 folder.
493                         # determine this from Python's libraries path
494                         #
495                         # ugh, its possible 'lib64' is just a symlink to 'lib' which causes incorrect use of 'lib64'
496                         get_filename_component(_pypath_real ${PYTHON_LIBPATH} REALPATH)
497                         if(${_pypath_real} MATCHES "lib64$")
498                                 set(_target_LIB "lib64")
499                         else()
500                                 set(_target_LIB "lib")
501                         endif()
502                         unset(_pypath_real)
503
504                         # Copy the systems python into the install directory
505                         # Scons copy in tools/Blender.py
506                         # install(CODE "message(\"copying a subset of the systems python...\")")
507                         install(
508                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
509                                 DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}
510                                 PATTERN ".svn" EXCLUDE
511                                 PATTERN "__pycache__" EXCLUDE               # * any cache *
512                                 PATTERN "distutils" EXCLUDE                 # ./distutils
513                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
514                                 PATTERN "config" EXCLUDE                    # ./config
515                                 PATTERN "config-*" EXCLUDE                  # ./config-*
516                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
517                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
518                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
519                                 PATTERN "idlelib" EXCLUDE                   # ./idlelib
520                                 PATTERN "test" EXCLUDE                      # ./test
521                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
522                                 PATTERN "turtle.py" EXCLUDE                 # ./turtle.py
523                         )
524
525                         # # doesnt work, todo
526                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
527
528                         if(WITH_PYTHON_INSTALL_NUMPY)
529                                 # Install to the same directory as the source, so debian-like
530                                 # distros are happy with their policy.
531                                 set(_suffix "site-packages")
532                                 if(${PYTHON_NUMPY_PATH} MATCHES "dist-packages")
533                                         set(_suffix "dist-packages")
534                                 endif()
535                                 install(
536                                         DIRECTORY ${PYTHON_NUMPY_PATH}/numpy
537                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
538                                         PATTERN ".svn" EXCLUDE
539                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
540                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
541                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
542                                         PATTERN "distutils" EXCLUDE             # ./distutils
543                                         PATTERN "oldnumeric" EXCLUDE            # ./oldnumeric
544                                         PATTERN "doc" EXCLUDE                   # ./doc
545                                         PATTERN "tests" EXCLUDE                 # ./tests
546                                         PATTERN "f2py" EXCLUDE                  # ./f2py - fortran/python interface code, not fun for blender devs.
547                                         PATTERN "include" EXCLUDE               # include dirs all over, we wont use NumPy/CAPI
548                                         PATTERN "*.h" EXCLUDE                   # some includes are not in include dirs
549                                         PATTERN "*.a" EXCLUDE                   # ./core/lib/libnpymath.a - for linking, we dont need.
550                                 )
551                                 unset(_suffix)
552                         endif()
553
554                         # Copy requests, we need to generalize site-packages
555                         if(WITH_PYTHON_INSTALL_REQUESTS)
556                                 set(_suffix "site-packages")
557                                 if(${PYTHON_REQUESTS_PATH} MATCHES "dist-packages")
558                                         set(_suffix "dist-packages")
559                                 endif()
560                                 install(
561                                         DIRECTORY ${PYTHON_REQUESTS_PATH}/requests
562                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
563                                         PATTERN ".svn" EXCLUDE
564                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
565                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
566                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
567                                         PATTERN "cacert.pem" EXCLUDE            # for now we don't deal with security
568                                 )
569                                 # On some platforms requests does have extra dependencies.
570                                 set(_requests_deps "chardet" "urllib3")
571                                 foreach(_requests_dep ${_requests_deps})
572                                         if(EXISTS ${PYTHON_REQUESTS_PATH}/${_requests_dep})
573                                                 install(
574                                                         DIRECTORY ${PYTHON_REQUESTS_PATH}/${_requests_dep}
575                                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
576                                                         PATTERN ".svn" EXCLUDE
577                                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
578                                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
579                                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
580                                                 )
581                                         endif()
582                                 endforeach()
583                                 if(EXISTS ${PYTHON_REQUESTS_PATH}/six.py)
584                                         install(
585                                                 FILES ${PYTHON_REQUESTS_PATH}/six.py
586                                                 DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
587                                         )
588                                         endif()
589                                 unset(_requests_dep)
590                                 unset(_requests_deps)
591                                 unset(_suffix)
592                         endif()
593                         unset(_target_LIB)
594                         
595                 endif()
596         endif()
597 elseif(WIN32)
598
599         install(
600                 FILES ${BLENDER_TEXT_FILES}
601                 DESTINATION ${TARGETDIR}
602         )
603
604         if(WITH_PYTHON)
605                 string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
606
607                 install(
608                         FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.dll ${LIBDIR}/python/lib/sqlite3.dll
609                         DESTINATION ${TARGETDIR}
610                         CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
611                 )
612
613                 install(
614                         FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll ${LIBDIR}/python/lib/sqlite3_d.dll
615                         DESTINATION ${TARGETDIR}
616                         CONFIGURATIONS Debug
617                 )
618
619                 if(WITH_PYTHON_INSTALL)
620                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
621
622                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
623                         install(
624                                 CODE
625                                 "
626                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
627                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\")
628                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\")
629                                 message(\"done creating dir\")
630                                 "
631                         )
632
633                         install(
634                                 CODE
635                                 "
636                                 if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
637                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
638                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_d.tar.gz\")
639                                 else()
640                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
641                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}.tar.gz\")
642                                 endif()
643                                 "
644                         )
645
646                         if(WITH_PYTHON_INSTALL_NUMPY)
647                                 install(
648                                         CODE
649                                         "
650                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/site-packages\"
651                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_1.8.tar.gz\")
652                                         "
653                                 )
654                         endif()
655
656                         # release/site-packages
657                         install(
658                                 CODE
659                                 "
660                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E copy_directory
661                                         ${LIBDIR}/release/site-packages
662                                         \"${TARGETDIR_VER}/python/lib/site-packages\")
663                                 "
664                         )
665
666
667                         # doesnt work, todo
668                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
669                 endif()
670
671                 unset(_PYTHON_VERSION_NO_DOTS)
672         endif()
673
674         if(MSVC)
675                 install(
676                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
677                         DESTINATION ${TARGETDIR}
678                 )
679         else()
680                 #MinGW64 comes with own version. For portable builds it will probaly have to be copied to work
681                 if(NOT WITH_MINGW64)
682                         install(
683                                 FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
684                                 DESTINATION ${TARGETDIR}
685                         )
686                 elseif(WITH_MINGW64)
687                         install(
688                                 FILES 
689                                         ${LIBDIR}/binaries/libgcc_s_sjlj-1.dll
690                                         ${LIBDIR}/binaries/libwinpthread-1.dll
691                                         ${LIBDIR}/binaries/libstdc++-6.dll
692                                 DESTINATION ${TARGETDIR}
693                         )
694                         
695                         if(WITH_OPENMP)
696                                 install(
697                                         FILES 
698                                         ${LIBDIR}/binaries/libgomp-1.dll
699                                         DESTINATION ${TARGETDIR}
700                                 )
701                         endif()
702                 endif()
703         endif()
704
705         if(WITH_CODEC_FFMPEG)
706                 if(WITH_MINGW64)
707                         install(
708                                 FILES
709                                         ${LIBDIR}/ffmpeg/lib/avcodec-53.dll
710                                         ${LIBDIR}/ffmpeg/lib/avformat-53.dll
711                                         ${LIBDIR}/ffmpeg/lib/avdevice-53.dll
712                                         ${LIBDIR}/ffmpeg/lib/avutil-51.dll
713                                         ${LIBDIR}/ffmpeg/lib/swscale-2.dll
714                                         ${LIBDIR}/ffmpeg/lib/swresample-0.dll
715                                         ${LIBDIR}/ffmpeg/lib/xvidcore.dll
716                                 DESTINATION ${TARGETDIR}
717                         )
718                 else()
719                         install(
720                                 FILES
721                                         ${LIBDIR}/ffmpeg/lib/avcodec-55.dll
722                                         ${LIBDIR}/ffmpeg/lib/avformat-55.dll
723                                         ${LIBDIR}/ffmpeg/lib/avdevice-55.dll
724                                         ${LIBDIR}/ffmpeg/lib/avutil-52.dll
725                                         ${LIBDIR}/ffmpeg/lib/swscale-2.dll
726                                 DESTINATION ${TARGETDIR}
727                         )
728                 endif()
729         endif()
730
731         if(WITH_CODEC_SNDFILE)
732                 install(
733                         FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
734                         DESTINATION ${TARGETDIR}
735                 )
736         endif()
737
738         if(WITH_OPENAL)
739                 install(
740                         FILES
741                                 ${LIBDIR}/openal/lib/OpenAL32.dll
742                                 ${LIBDIR}/openal/lib/wrap_oal.dll
743                         DESTINATION ${TARGETDIR}
744                 )
745         endif()
746
747         if(WITH_SDL)
748                 install(
749                         FILES ${LIBDIR}/sdl/lib/SDL.dll
750                         DESTINATION ${TARGETDIR}
751                 )
752         endif()
753
754         if(NOT CMAKE_CL_64)
755                 install(
756                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
757                         DESTINATION ${TARGETDIR}
758                 )
759         endif()
760                 
761         install( # x86 builds can run on x64 Windows, so this is required at all times
762                 FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
763                 DESTINATION ${TARGETDIR}
764         )
765
766         if(WITH_OPENCOLORIO)
767                 set(OCIOBIN ${LIBDIR}/opencolorio/bin)
768                 if(NOT MINGW)
769                         install(
770                                 FILES
771                                         ${OCIOBIN}/OpenColorIO.dll
772                                 DESTINATION ${TARGETDIR}
773                         )
774                 else()
775                         install(
776                                 FILES
777                                         ${OCIOBIN}/libOpenColorIO.dll
778                                 DESTINATION ${TARGETDIR}
779                         )
780                 endif()
781         endif()
782
783 elseif(APPLE)
784
785         # handy install macro to exclude files, we use \$ escape for the "to"
786         # argument when calling so ${BUILD_TYPE} does not get expanded
787         macro(install_dir from to)
788                 install(
789                         DIRECTORY ${from}
790                         DESTINATION ${to}
791                         PATTERN ".git" EXCLUDE
792                         PATTERN ".svn" EXCLUDE
793                         PATTERN "*.pyc" EXCLUDE
794                         PATTERN "*.pyo" EXCLUDE
795                         PATTERN "*.orig" EXCLUDE
796                         PATTERN "*.rej" EXCLUDE
797                         PATTERN "__pycache__" EXCLUDE
798                         PATTERN "__MACOSX" EXCLUDE
799                         PATTERN ".DS_Store" EXCLUDE
800                 )
801         endmacro()
802
803         set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blender.app)
804
805         # setup Info.plist
806         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
807
808         set_target_properties(blender PROPERTIES
809                 MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist
810                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
811                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
812
813
814         # install release and app files
815         install(
816                 FILES ${BLENDER_TEXT_FILES}
817                 DESTINATION ${TARGETDIR}
818         )
819
820         install(
821                 FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo
822                 DESTINATION ${TARGETDIR}/blender.app/Contents
823         )
824
825         install_dir(
826                 ${OSX_APP_SOURCEDIR}/Contents/Resources
827                 \${TARGETDIR}/blender.app/Contents/
828         )
829
830         if(WITH_OPENMP AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT ${CMAKE_C_COMPILER_VERSION} VERSION_LESS '3.4')
831                 install(
832                         FILES ${LIBDIR}/openmp/lib/libiomp5.dylib
833                         DESTINATION ${TARGETDIR}/blender.app/Contents/MacOS
834                 )
835         endif()
836
837         if(WITH_LLVM AND NOT LLVM_STATIC)
838                 install(
839                         FILES ${LIBDIR}/llvm/lib/libLLVM-3.4.dylib
840                         DESTINATION ${TARGETDIR}/blender.app/Contents/MacOS
841                 )
842         endif()
843
844         # python
845         if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
846                 # the python zip is first extract as part of the build process,
847                 # and then later installed as part of make install. this is much
848                 # quicker, and means we can easily exclude files on copy
849                 # Not needed for PYTHON_MODULE or WEB_PLUGIN due uses  Pyhon framework
850                 add_custom_target(
851                         extractpyzip
852                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
853
854                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
855
856                 add_custom_command(
857                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
858                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
859                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
860                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
861                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
862
863                 add_dependencies(blender extractpyzip)
864
865                 # copy extracted python files
866                 install_dir(
867                         ${CMAKE_CURRENT_BINARY_DIR}/python
868                         \${TARGETDIR_VER}
869                 )
870                 # copy site-packages files
871                 install_dir(
872                         ${LIBDIR}/release/site-packages
873                         ${CMAKE_CURRENT_BINARY_DIR}/python/lib/python${PYTHON_VERSION}/site-packages
874                 )
875
876         endif()
877         
878         # install blenderplayer bundle - copy of blender.app above. re-using macros et al
879         # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
880         if(WITH_GAMEENGINE AND WITH_PLAYER)
881                 set(OSX_APP_PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blenderplayer.app)
882                 set(PLAYER_SOURCEINFO ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Info.plist)
883                 set(PLAYER_TARGETDIR_VER ${TARGETDIR}/blenderplayer.app/Contents/MacOS/${BLENDER_VERSION})
884
885
886                 # important to make a clean  install each time else old scripts get loaded.
887                 install(
888                         CODE
889                         "file(REMOVE_RECURSE ${PLAYER_TARGETDIR_VER})"
890                 )
891
892                 install(
893                         FILES ${OSX_APP_PLAYER_SOURCEDIR}/Contents/PkgInfo
894                         DESTINATION ${TARGETDIR}/blenderplayer.app/Contents
895                 )
896
897                 install_dir(
898                         ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Resources
899                         \${TARGETDIR}/blenderplayer.app/Contents/
900                 )
901
902                 # python
903                 if(WITH_PYTHON AND NOT WITH_PYTHON_FRAMEWORK)
904                         add_custom_command(
905                                 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
906                                 COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
907                                 COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
908                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
909                                 DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
910
911                         # copy extracted python files
912                         install_dir(
913                                 ${CMAKE_CURRENT_BINARY_DIR}/python
914                                 \${PLAYER_TARGETDIR_VER}
915                         )
916                 endif()
917
918         endif()
919
920 endif()
921
922 # -----------------------------------------------------------------------------
923 # Generic Install, for all targets
924
925
926
927 # install more files specified elsewhere
928 delayed_do_install(${TARGETDIR_VER})
929
930 unset(BLENDER_TEXT_FILES)
931
932
933 # -----------------------------------------------------------------------------
934 # Setup link libs
935
936 add_dependencies(blender makesdna)
937
938 setup_blender_sorted_libs()
939
940 target_link_libraries(blender ${BLENDER_SORTED_LIBS})
941
942 setup_liblinks(blender)
943
944 # -----------------------------------------------------------------------------
945 # Setup launcher
946
947 if(WIN32 AND NOT WITH_PYTHON_MODULE)
948         set(LAUNCHER_SRC
949                 creator_launch_win.c
950                 ../icons/winblender.rc
951         )
952         add_executable(blender-launcher ${LAUNCHER_SRC})
953         target_link_libraries(blender-launcher bf_intern_utfconv ${PLATFORM_LINKLIBS})
954
955         set_target_properties(blender PROPERTIES OUTPUT_NAME blender-app)
956         set_target_properties(blender-launcher PROPERTIES OUTPUT_NAME blender)
957 endif()