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