Bevel Factor Mapping
[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 endif()
178
179 # message(STATUS "Configuring blender")
180 if(WITH_PYTHON_MODULE)
181         add_definitions(-DWITH_PYTHON_MODULE)
182
183         # creates ./bin/bpy.so which can be imported as a python module.
184         #
185         # note that 'SHARED' works on Linux and Windows,
186         # but not OSX which _must_ be 'MODULE'
187         add_library(blender MODULE ${SRC})
188         set_target_properties(
189                 blender
190                 PROPERTIES
191                         PREFIX ""
192                         OUTPUT_NAME bpy
193                         LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
194                         RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin  # only needed on windows
195         )
196
197         if(APPLE)
198                 set_target_properties(
199                         blender
200                         PROPERTIES
201                                 LINK_FLAGS_RELEASE "${PLATFORM_LINKFLAGS}"
202                                 LINK_FLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG}"
203                 )
204         endif()
205
206         if(WIN32)
207                 # python modules use this
208                 set_target_properties(
209                         blender
210                         PROPERTIES
211                         SUFFIX ".pyd"
212                 )
213         endif()
214
215 else()
216         add_executable(blender ${EXETYPE} ${SRC})
217 endif()
218
219 if(WITH_BUILDINFO)
220         # explicitly say that the executable depends on the buildinfo
221         add_dependencies(blender buildinfo)
222 endif()
223
224 # Post build steps for bundling/packaging.
225
226
227 if(MSVC_IDE)
228         # ${CMAKE_CFG_INTDIR} should replace \${BUILD_TYPE} when using add_command
229         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE})
230 elseif(APPLE)
231         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE})
232 else()
233         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH})
234 endif()
235
236 set(BLENDER_TEXT_FILES
237         ${CMAKE_SOURCE_DIR}/release/text/GPL-license.txt
238         ${CMAKE_SOURCE_DIR}/release/text/Python-license.txt
239         ${CMAKE_SOURCE_DIR}/release/text/copyright.txt
240         ${CMAKE_SOURCE_DIR}/release/text/readme.html
241         ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-bfont.ttf.txt
242 )
243
244 if(WITH_INTERNATIONAL)
245         list(APPEND BLENDER_TEXT_FILES
246                 ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-droidsans.ttf.txt
247                 ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-bmonofont-i18n.ttf.txt
248         )
249 endif()
250
251
252 # -----------------------------------------------------------------------------
253 # Platform Specific Var: TARGETDIR_VER
254
255 if(UNIX AND NOT APPLE)
256         if(WITH_INSTALL_PORTABLE)
257                 set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
258         else()
259                 if(WITH_PYTHON_MODULE)
260                         set(TARGETDIR_VER ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/${BLENDER_VERSION})
261                 else()
262                         set(TARGETDIR_VER ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION})
263                 endif()
264         endif()
265
266 elseif(WIN32)
267         set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
268
269 elseif(APPLE)
270         if(WITH_PYTHON_MODULE)
271                 set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
272         else()
273                 set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
274         endif()
275
276 endif()
277
278
279 # -----------------------------------------------------------------------------
280 # Install Targets (Generic, All Platforms)
281
282
283 # important to make a clean  install each time, else old scripts get loaded.
284 install(
285         CODE
286         "file(REMOVE_RECURSE ${TARGETDIR_VER})"
287 )
288
289 if(WITH_PYTHON)
290         # install(CODE "message(\"copying blender scripts...\")")
291         
292         # exclude addons_contrib if release
293         if("${BLENDER_VERSION_CYCLE}" STREQUAL "release")
294                 set(ADDON_EXCLUDE_CONDITIONAL "addons_contrib/*")
295         else()
296                 set(ADDON_EXCLUDE_CONDITIONAL "_addons_contrib/*")  # dummy, wont do anything
297         endif()
298
299         # do not install freestyle dir if disabled
300         if(NOT WITH_FREESTYLE)
301                 set(FREESTYLE_EXCLUDE_CONDITIONAL "freestyle/*")
302         else()
303                 set(FREESTYLE_EXCLUDE_CONDITIONAL "_freestyle/*")  # dummy, wont do anything
304         endif()
305
306         install(
307                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
308                 DESTINATION ${TARGETDIR_VER}
309                 PATTERN ".git" EXCLUDE
310                 PATTERN "__pycache__" EXCLUDE
311                 PATTERN "${ADDON_EXCLUDE_CONDITIONAL}" EXCLUDE
312                 PATTERN "${FREESTYLE_EXCLUDE_CONDITIONAL}" EXCLUDE
313         )
314         
315         unset(ADDON_EXCLUDE_CONDITIONAL)
316         unset(FREESTYLE_EXCLUDE_CONDITIONAL)
317 endif()
318
319 # localization
320 if(WITH_INTERNATIONAL)
321         install(
322                 DIRECTORY
323                         ${CMAKE_SOURCE_DIR}/release/datafiles/fonts
324                 DESTINATION ${TARGETDIR_VER}/datafiles
325         )
326
327         set(_locale_dir "${CMAKE_SOURCE_DIR}/release/datafiles/locale")
328         set(_locale_target_dir ${TARGETDIR_VER}/datafiles/locale)
329
330         file(GLOB _po_files "${_locale_dir}/po/*.po")
331         foreach(_po_file ${_po_files})
332                 msgfmt_simple(${_po_file} _all_mo_files)
333         endforeach()
334
335         # Create a custom target which will compile all po to mo
336         add_custom_target(
337                 locales
338                 DEPENDS ${_all_mo_files})
339
340         add_dependencies(blender locales)
341
342         # Generate INSTALL rules
343         install(
344                 FILES ${_locale_dir}/languages
345                 DESTINATION ${_locale_target_dir}
346         )
347
348         foreach(_mo_file ${_all_mo_files})
349                 get_filename_component(_locale_name ${_mo_file} NAME_WE)
350                 install(
351                         FILES ${_mo_file}
352                         DESTINATION ${_locale_target_dir}/${_locale_name}/LC_MESSAGES
353                         RENAME blender.mo
354                 )
355                 unset(_locale_name)
356         endforeach()
357
358         unset(_all_mo_files)
359         unset(_po_files)
360         unset(_po_file)
361         unset(_mo_file)
362         unset(_locale_target_dir)
363
364         unset(_locale_dir)
365 endif()
366
367 # color management
368 if(WITH_OPENCOLORIO)
369         install(
370                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/colormanagement
371                 DESTINATION ${TARGETDIR_VER}/datafiles
372         )
373 endif()
374
375 # helpful tip when using make
376 if("${CMAKE_GENERATOR}" MATCHES ".*Makefiles.*")
377         # message after building.
378         add_custom_command(
379                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
380                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files and scripts to ${TARGETDIR_VER}'
381         )
382 endif()
383
384
385 # -----------------------------------------------------------------------------
386 # Install Targets (Platform Specific)
387
388 if(UNIX AND NOT APPLE)
389
390         # there are a few differences between portable and system install
391         if(WITH_INSTALL_PORTABLE)
392                 install(
393                         FILES
394                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
395                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
396                                 ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
397                         DESTINATION ${TARGETDIR}
398                 )
399
400                 install(
401                         PROGRAMS
402                         ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
403                         DESTINATION ${TARGETDIR}
404                 )
405
406                 install(
407                         FILES ${BLENDER_TEXT_FILES}
408                         DESTINATION ${TARGETDIR}
409                 )
410
411         else()
412                 # main blender binary
413                 if(WITH_PYTHON_MODULE)
414                         install(
415                                 TARGETS blender
416                                 LIBRARY
417                                 DESTINATION ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages
418                         )
419                 else()
420                         install(
421                                 PROGRAMS ${TARGETDIR}/blender
422                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
423                         )
424                 endif()
425
426
427                 if(WITH_GAMEENGINE AND WITH_PLAYER)
428                         install(
429                                 PROGRAMS ${TARGETDIR}/blenderplayer
430                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
431                         )
432                 endif()
433
434                 # misc files
435                 install(
436                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
437                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
438                 )
439                 install(
440                         DIRECTORY
441                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/16x16
442                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/22x22
443                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/24x24
444                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/32x32
445                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48
446                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256
447                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor
448                         PATTERN "*.svg" EXCLUDE
449                 )
450                 install(
451                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
452                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps
453                 )
454                 install(
455                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
456                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
457                 )
458                 install(
459                         FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
460                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
461                 )
462                 install(
463                         FILES ${BLENDER_TEXT_FILES}
464                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
465                 )
466         endif()
467
468         if(WITH_PYTHON)
469                 if(WITH_PYTHON_INSTALL)
470                         # on some platforms (like openSUSE) Python is linked
471                         # to be used from lib64 folder.
472                         # determine this from Python's libraries path
473                         #
474                         # ugh, its possible 'lib64' is just a symlink to 'lib' which causes incorrect use of 'lib64'
475                         get_filename_component(_pypath_real ${PYTHON_LIBPATH} REALPATH)
476                         if(${_pypath_real} MATCHES "lib64$")
477                                 set(_target_LIB "lib64")
478                         else()
479                                 set(_target_LIB "lib")
480                         endif()
481                         unset(_pypath_real)
482
483                         # Copy the systems python into the install directory
484                         # Scons copy in tools/Blender.py
485                         # install(CODE "message(\"copying a subset of the systems python...\")")
486                         install(
487                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
488                                 DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}
489                                 PATTERN ".svn" EXCLUDE
490                                 PATTERN "__pycache__" EXCLUDE               # * any cache *
491                                 PATTERN "distutils" EXCLUDE                 # ./distutils
492                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
493                                 PATTERN "config" EXCLUDE                    # ./config
494                                 PATTERN "config-*" EXCLUDE                  # ./config-*
495                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
496                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
497                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
498                                 PATTERN "idlelib" EXCLUDE                   # ./idlelib
499                                 PATTERN "test" EXCLUDE                      # ./test
500                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
501                                 PATTERN "turtle.py" EXCLUDE                                     # ./turtle.py
502                         )
503
504                         # # doesnt work, todo
505                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
506                         
507                         if(WITH_PYTHON_INSTALL_NUMPY)
508                                 install(
509                                         DIRECTORY ${PYTHON_NUMPY_PATH}/numpy
510                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/site-packages
511                                         PATTERN ".svn" EXCLUDE
512                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
513                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
514                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
515                                         PATTERN "distutils" EXCLUDE             # ./distutils
516                                         PATTERN "oldnumeric" EXCLUDE            # ./oldnumeric
517                                         PATTERN "doc" EXCLUDE                   # ./doc
518                                         PATTERN "tests" EXCLUDE                 # ./tests
519                                         PATTERN "f2py" EXCLUDE                  # ./f2py - fortran/python interface code, not fun for blender devs.
520                                         PATTERN "include" EXCLUDE               # include dirs all over, we wont use NumPy/CAPI
521                                         PATTERN "*.h" EXCLUDE                   # some includes are not in include dirs
522                                         PATTERN "*.a" EXCLUDE                   # ./core/lib/libnpymath.a - for linking, we dont need.
523                                 )
524                         endif()
525
526                         # Copy requests, we need to generalize site-packages
527                         if(WITH_PYTHON_INSTALL_REQUESTS)
528                                 install(
529                                         DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/requests
530                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/site-packages
531                                         PATTERN ".svn" EXCLUDE
532                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
533                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
534                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
535                                         PATTERN "cacert.pem" EXCLUDE            # for now we don't deal with security
536                                 )
537                         endif()
538                         unset(_target_LIB)
539                         
540                 endif()
541         endif()
542 elseif(WIN32)
543
544         install(
545                 FILES ${BLENDER_TEXT_FILES}
546                 DESTINATION ${TARGETDIR}
547         )
548
549         if(WITH_PYTHON)
550                 string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
551
552                 install(
553                         FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.dll
554                         DESTINATION ${TARGETDIR}
555                         CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
556                 )
557
558                 install(
559                         FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll
560                         DESTINATION ${TARGETDIR}
561                         CONFIGURATIONS Debug
562                 )
563
564                 if(WITH_PYTHON_INSTALL)
565                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
566
567                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
568                         install(
569                                 CODE
570                                 "
571                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
572                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\")
573                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\")
574                                 message(\"done creating dir\")
575                                 "
576                         )
577
578                         install(
579                                 CODE
580                                 "
581                                 if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
582                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
583                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_d.tar.gz\")
584                                 else()
585                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
586                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}.tar.gz\")
587                                 endif()
588                                 "
589                         )
590
591                         if(WITH_PYTHON_INSTALL_NUMPY)
592                                 install(
593                                         CODE
594                                         "
595                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/site-packages\"
596                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_1.8.tar.gz\")
597                                         "
598                                 )
599                         endif()
600
601                         # release/site-packages
602                         install(
603                                 CODE
604                                 "
605                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E copy_directory
606                                         ${LIBDIR}/release/site-packages
607                                         \"${TARGETDIR_VER}/python/lib/site-packages\")
608                                 "
609                         )
610
611
612                         # doesnt work, todo
613                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
614                 endif()
615
616                 unset(_PYTHON_VERSION_NO_DOTS)
617         endif()
618
619         if(MSVC)
620                 install(
621                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
622                         DESTINATION ${TARGETDIR}
623                 )
624         else()
625                 #MinGW64 comes with own version. For portable builds it will probaly have to be copied to work
626                 if(NOT WITH_MINGW64)
627                         install(
628                                 FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
629                                 DESTINATION ${TARGETDIR}
630                         )
631                 elseif(WITH_MINGW64)
632                         install(
633                                 FILES 
634                                         ${LIBDIR}/binaries/libgcc_s_sjlj-1.dll
635                                         ${LIBDIR}/binaries/libwinpthread-1.dll
636                                         ${LIBDIR}/binaries/libstdc++-6.dll
637                                 DESTINATION ${TARGETDIR}
638                         )
639                         
640                         if(WITH_OPENMP)
641                                 install(
642                                         FILES 
643                                         ${LIBDIR}/binaries/libgomp-1.dll
644                                         DESTINATION ${TARGETDIR}
645                                 )
646                         endif()
647                 endif()
648         endif()
649
650         if(WITH_CODEC_FFMPEG)
651                 if(MSVC11)
652                         install(
653                                 FILES
654                                         ${LIBDIR}/ffmpeg/lib/avcodec-54.dll
655                                         ${LIBDIR}/ffmpeg/lib/avformat-54.dll
656                                         ${LIBDIR}/ffmpeg/lib/avdevice-54.dll
657                                         ${LIBDIR}/ffmpeg/lib/avutil-52.dll
658                                         ${LIBDIR}/ffmpeg/lib/avfilter-3.dll
659                                         ${LIBDIR}/ffmpeg/lib/swresample-0.dll
660                                         ${LIBDIR}/ffmpeg/lib/swscale-2.dll
661                                 DESTINATION ${TARGETDIR}
662                         )
663                 else()
664                         install(
665                                 FILES
666                                         ${LIBDIR}/ffmpeg/lib/avcodec-55.dll
667                                         ${LIBDIR}/ffmpeg/lib/avformat-55.dll
668                                         ${LIBDIR}/ffmpeg/lib/avdevice-55.dll
669                                         ${LIBDIR}/ffmpeg/lib/avutil-52.dll
670                                         ${LIBDIR}/ffmpeg/lib/swscale-2.dll
671                                 DESTINATION ${TARGETDIR}
672                         )
673                 endif()
674                 if(WITH_MINGW64)
675                 install(
676                         FILES
677                                 ${LIBDIR}/ffmpeg/lib/swresample-0.dll
678                                 ${LIBDIR}/ffmpeg/lib/xvidcore.dll
679                         DESTINATION ${TARGETDIR}
680                 )
681                 endif()
682         endif()
683
684         if(WITH_CODEC_SNDFILE)
685                 install(
686                         FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
687                         DESTINATION ${TARGETDIR}
688                 )
689         endif()
690
691         if(WITH_OPENAL)
692                 if(MSVC11)
693                         install(
694                                 FILES
695                                         ${LIBDIR}/openal/lib/OpenAL32.dll
696                                 DESTINATION ${TARGETDIR}
697                         )
698                 else()
699                         install(
700                                 FILES
701                                         ${LIBDIR}/openal/lib/OpenAL32.dll
702                                         ${LIBDIR}/openal/lib/wrap_oal.dll
703                                 DESTINATION ${TARGETDIR}
704                         )
705                 endif()
706         endif()
707
708 #       if(WITH_JACK AND MSVC11)
709 #               if(CMAKE_CL_64)
710 #                       install(
711 #                               FILES
712 #                                       ${LIBDIR}/jack/lib/libjack64.dll
713 #                               DESTINATION ${TARGETDIR}
714 #                       )
715 #               else()
716 #                       install(
717 #                               FILES
718 #                                       ${LIBDIR}/jack/lib/libjack.dll
719 #                               DESTINATION ${TARGETDIR}
720 #                       )
721 #               endif()
722 #       endif()
723
724         if(WITH_SDL)
725                 if(NOT CMAKE_CL_64)
726                         install(
727                                 FILES ${LIBDIR}/sdl/lib/SDL.dll
728                                 DESTINATION ${TARGETDIR}
729                         )
730                 endif()
731         endif()
732
733         if(NOT CMAKE_CL_64)
734                 install(
735                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
736                         DESTINATION ${TARGETDIR}
737                 )
738         endif()
739                 
740         install( # x86 builds can run on x64 Windows, so this is required at all times
741                 FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
742                 DESTINATION ${TARGETDIR}
743         )
744
745         if(WITH_OPENCOLORIO)
746                 set(OCIOBIN ${LIBDIR}/opencolorio/bin)
747                 if(NOT MINGW)
748                         install(
749                                 FILES
750                                         ${OCIOBIN}/OpenColorIO.dll
751                                 DESTINATION ${TARGETDIR}
752                         )
753                 else()
754                         install(
755                                 FILES
756                                         ${OCIOBIN}/libOpenColorIO.dll
757                                 DESTINATION ${TARGETDIR}
758                         )
759                 endif()
760         endif()
761
762 elseif(APPLE)
763
764         # handy install macro to exclude files, we use \$ escape for the "to"
765         # argument when calling so ${BUILD_TYPE} does not get expanded
766         macro(install_dir from to)
767                 install(
768                         DIRECTORY ${from}
769                         DESTINATION ${to}
770                         PATTERN ".git" EXCLUDE
771                         PATTERN ".svn" EXCLUDE
772                         PATTERN "*.pyc" EXCLUDE
773                         PATTERN "*.pyo" EXCLUDE
774                         PATTERN "*.orig" EXCLUDE
775                         PATTERN "*.rej" EXCLUDE
776                         PATTERN "__pycache__" EXCLUDE
777                         PATTERN "__MACOSX" EXCLUDE
778                         PATTERN ".DS_Store" EXCLUDE
779                 )
780         endmacro()
781
782         set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blender.app)
783
784         # setup Info.plist
785         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
786
787         set_target_properties(blender PROPERTIES
788                 MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist
789                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
790                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
791
792
793         # install release and app files
794         install(
795                 FILES ${BLENDER_TEXT_FILES}
796                 DESTINATION ${TARGETDIR}
797         )
798
799         install(
800                 FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo
801                 DESTINATION ${TARGETDIR}/blender.app/Contents
802         )
803
804         install_dir(
805                 ${OSX_APP_SOURCEDIR}/Contents/Resources
806                 \${TARGETDIR}/blender.app/Contents/
807         )
808
809         if(WITH_OPENMP AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT ${CMAKE_C_COMPILER_VERSION} VERSION_LESS '3.4')
810                 install(
811                         FILES ${LIBDIR}/openmp/lib/libiomp5.dylib
812                         DESTINATION ${TARGETDIR}/blender.app/Contents/MacOS
813                 )
814         endif()
815
816         # python
817         if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
818                 # the python zip is first extract as part of the build process,
819                 # and then later installed as part of make install. this is much
820                 # quicker, and means we can easily exclude files on copy
821                 # Not needed for PYTHON_MODULE or WEB_PLUGIN due uses  Pyhon framework
822                 add_custom_target(
823                         extractpyzip
824                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
825
826                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
827
828                 add_custom_command(
829                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
830                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
831                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
832                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
833                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
834
835                 add_dependencies(blender extractpyzip)
836
837                 # copy extracted python files
838                 install_dir(
839                         ${CMAKE_CURRENT_BINARY_DIR}/python
840                         \${TARGETDIR_VER}
841                 )
842                 # copy site-packages files
843                 install_dir(
844                         ${LIBDIR}/release/site-packages
845                         ${CMAKE_CURRENT_BINARY_DIR}/python/lib/python${PYTHON_VERSION}/site-packages
846                 )
847
848         endif()
849         
850         # install blenderplayer bundle - copy of blender.app above. re-using macros et al
851         # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
852         if(WITH_GAMEENGINE AND WITH_PLAYER)
853                 set(OSX_APP_PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blenderplayer.app)
854                 set(PLAYER_SOURCEINFO ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Info.plist)
855                 set(PLAYER_TARGETDIR_VER ${TARGETDIR}/blenderplayer.app/Contents/MacOS/${BLENDER_VERSION})
856
857
858                 # important to make a clean  install each time else old scripts get loaded.
859                 install(
860                         CODE
861                         "file(REMOVE_RECURSE ${PLAYER_TARGETDIR_VER})"
862                 )
863
864                 install(
865                         FILES ${OSX_APP_PLAYER_SOURCEDIR}/Contents/PkgInfo
866                         DESTINATION ${TARGETDIR}/blenderplayer.app/Contents
867                 )
868
869                 install_dir(
870                         ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Resources
871                         \${TARGETDIR}/blenderplayer.app/Contents/
872                 )
873
874                 # python
875                 if(WITH_PYTHON AND NOT WITH_PYTHON_FRAMEWORK)
876                         add_custom_command(
877                                 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
878                                 COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
879                                 COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
880                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
881                                 DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
882
883                         # copy extracted python files
884                         install_dir(
885                                 ${CMAKE_CURRENT_BINARY_DIR}/python
886                                 \${PLAYER_TARGETDIR_VER}
887                         )
888                 endif()
889
890         endif()
891
892 endif()
893
894 # -----------------------------------------------------------------------------
895 # Generic Install, for all targets
896
897
898
899 # install more files specified elsewhere
900 delayed_do_install(${TARGETDIR_VER})
901
902 unset(BLENDER_TEXT_FILES)
903
904
905 # -----------------------------------------------------------------------------
906 # Setup link libs
907
908 add_dependencies(blender makesdna)
909
910 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
911
912 list(APPEND BLENDER_LINK_LIBS
913         bf_windowmanager
914         bf_render
915 )
916
917 if(WITH_MOD_FLUID)
918         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
919 endif()
920
921 if(WITH_CYCLES)
922         list(APPEND BLENDER_LINK_LIBS
923                 cycles_render
924                 cycles_bvh
925                 cycles_device
926                 cycles_kernel
927                 cycles_util
928                 cycles_subd)
929         if(WITH_CYCLES_OSL)
930                 list(APPEND BLENDER_LINK_LIBS cycles_kernel_osl)
931         endif()
932 endif()
933
934 #if(UNIX)
935         # Sort libraries
936         set(BLENDER_SORTED_LIBS
937                 bf_windowmanager
938
939                 bf_editor_space_api
940                 bf_editor_space_action
941                 bf_editor_space_buttons
942                 bf_editor_space_console
943                 bf_editor_space_file
944                 bf_editor_space_graph
945                 bf_editor_space_image
946                 bf_editor_space_info
947                 bf_editor_space_logic
948                 bf_editor_space_nla
949                 bf_editor_space_node
950                 bf_editor_space_outliner
951                 bf_editor_space_script
952                 bf_editor_space_sequencer
953                 bf_editor_space_text
954                 bf_editor_space_time
955                 bf_editor_space_userpref
956                 bf_editor_space_view3d
957                 bf_editor_space_clip
958
959                 bf_editor_transform
960                 bf_editor_util
961                 bf_editor_uvedit
962                 bf_editor_curve
963                 bf_editor_gpencil
964                 bf_editor_interface
965                 bf_editor_mesh
966                 bf_editor_metaball
967                 bf_editor_object
968                 bf_editor_armature
969                 bf_editor_physics
970                 bf_editor_render
971                 bf_editor_screen
972                 bf_editor_sculpt_paint
973                 bf_editor_sound
974                 bf_editor_animation
975                 bf_editor_datafiles
976                 bf_editor_mask
977                 bf_editor_io
978
979                 bf_render
980                 bf_python
981                 bf_python_ext
982                 bf_python_mathutils
983                 bf_python_bmesh
984                 bf_freestyle
985                 bf_ikplugin
986                 bf_modifiers
987                 bf_bmesh
988                 bf_blenkernel
989                 bf_nodes
990                 bf_gpu
991                 bf_blenloader
992                 bf_imbuf
993                 bf_blenlib
994                 bf_intern_ghost
995                 bf_intern_string
996                 bf_avi
997                 bf_imbuf_cineon
998                 bf_imbuf_openexr
999                 bf_imbuf_openimageio
1000                 bf_imbuf_dds
1001                 bf_collada
1002                 bf_intern_elbeem
1003                 bf_intern_memutil
1004                 bf_intern_guardedalloc
1005                 bf_intern_ctr
1006                 bf_intern_utfconv
1007                 ge_blen_routines
1008                 ge_converter
1009                 ge_phys_dummy
1010                 ge_phys_bullet
1011                 bf_intern_smoke
1012                 extern_minilzo
1013                 extern_lzma
1014                 extern_colamd
1015                 ge_logic_ketsji
1016                 extern_recastnavigation
1017                 ge_logic
1018                 ge_rasterizer
1019                 ge_oglrasterizer
1020                 ge_logic_expressions
1021                 ge_scenegraph
1022                 ge_logic_network
1023                 ge_logic_ngnetwork
1024                 ge_logic_loopbacknetwork
1025                 bf_intern_moto
1026                 extern_openjpeg
1027                 extern_redcode
1028                 ge_videotex
1029                 bf_rna
1030                 bf_dna
1031                 bf_blenfont
1032                 bf_intern_audaspace
1033                 bf_intern_mikktspace
1034                 bf_intern_dualcon
1035                 bf_intern_cycles
1036                 cycles_render
1037                 cycles_bvh
1038                 cycles_device
1039                 cycles_kernel
1040                 cycles_util
1041                 cycles_subd
1042                 bf_intern_raskter
1043                 bf_intern_opencolorio
1044                 extern_rangetree
1045                 extern_wcwidth
1046                 extern_libmv
1047         )
1048
1049         if(WITH_COMPOSITOR)
1050                 # added for opencl compositor
1051                 list_insert_before(BLENDER_SORTED_LIBS "bf_blenkernel" "bf_compositor")
1052                 list_insert_after(BLENDER_SORTED_LIBS "bf_compositor" "bf_intern_opencl")
1053         endif()
1054
1055         if(WITH_LIBMV)
1056                 list(APPEND BLENDER_SORTED_LIBS extern_ceres)
1057         endif()
1058
1059         if(WITH_MOD_CLOTH_ELTOPO)
1060                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
1061         endif()
1062
1063         if(NOT WITH_SYSTEM_GLEW)
1064                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
1065         endif()
1066
1067         if(WITH_BINRELOC)
1068                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
1069         endif()
1070
1071         if(WITH_CXX_GUARDEDALLOC)
1072                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
1073         endif()
1074
1075         if(WITH_IK_SOLVER)
1076                 list_insert_after(BLENDER_SORTED_LIBS "bf_intern_elbeem" "bf_intern_iksolver")
1077         endif()
1078
1079         if(WITH_IK_ITASC)
1080                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
1081         endif()
1082
1083         if(WITH_CODEC_QUICKTIME)
1084                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
1085         endif()
1086
1087         if(WITH_INPUT_NDOF)
1088                 list(APPEND BLENDER_SORTED_LIBS bf_intern_ghostndof3dconnexion)
1089         endif()
1090         
1091         if(WITH_MOD_BOOLEAN)
1092                 list(APPEND BLENDER_SORTED_LIBS extern_carve)
1093         endif()
1094
1095         if(WITH_GHOST_XDND)
1096                 list(APPEND BLENDER_SORTED_LIBS extern_xdnd)
1097         endif()
1098
1099         if(WITH_CYCLES_OSL)
1100                 list_insert_after(BLENDER_SORTED_LIBS "cycles_kernel" "cycles_kernel_osl")
1101         endif()
1102
1103         if(WITH_INTERNATIONAL)
1104                 list(APPEND BLENDER_SORTED_LIBS bf_intern_locale)
1105         endif()
1106
1107         if(WITH_OPENNL)
1108                 list_insert_after(BLENDER_SORTED_LIBS "bf_render" "bf_intern_opennl")
1109         endif()
1110
1111         if(WITH_BULLET)
1112                 list_insert_after(BLENDER_SORTED_LIBS "bf_blenkernel" "bf_intern_rigidbody")
1113         endif()
1114
1115         if(WITH_BULLET AND NOT WITH_SYSTEM_BULLET)
1116                 list_insert_after(BLENDER_SORTED_LIBS "ge_logic_ngnetwork" "extern_bullet")
1117         endif()
1118
1119         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
1120                 set(REMLIB ${SORTLIB})
1121                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
1122                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
1123                                 set(REMLIB "")
1124                         endif()
1125                 endforeach()
1126                 if(REMLIB)
1127                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
1128                         list(APPEND REM_MSG ${REMLIB})
1129                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
1130                 endif()
1131         endforeach()
1132         if(REM_MSG)
1133                 list(SORT REM_MSG)
1134                 message(STATUS "Blender Skipping: (${REM_MSG})")
1135         endif()
1136         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
1137
1138         unset(SEARCHLIB)
1139         unset(SORTLIB)
1140         unset(REMLIB)
1141         unset(REM_MSG)
1142
1143 #else()
1144 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
1145 #endif()
1146
1147 setup_liblinks(blender)