Fix for #34739 and #35060, avoid ambiguity in compositor viewer nodes.
[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_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                 set_lib_path(PYLIB "python")
492
493                 string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
494
495                 install(
496                         FILES ${PYLIB}/lib/python${_PYTHON_VERSION_NO_DOTS}.dll
497                         DESTINATION ${TARGETDIR}
498                         CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
499                 )
500
501                 install(
502                         FILES ${PYLIB}/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll
503                         DESTINATION ${TARGETDIR}
504                         CONFIGURATIONS Debug
505                 )
506
507                 if(WITH_PYTHON_INSTALL)
508                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
509
510                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
511                         install(
512                                 CODE
513                                 "
514                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
515                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\")
516                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\")
517                                 message(\"done creating dir\")
518                                 "
519                         )
520
521                         install(
522                                 CODE
523                                 "
524                                 if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
525                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
526                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_d.tar.gz\")
527                                 else()
528                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
529                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}.tar.gz\")
530                                 endif()
531                                 "
532                         )
533
534                         # doesnt work, todo
535                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
536                 endif()
537
538                 unset(_PYTHON_VERSION_NO_DOTS)
539         endif()
540
541         if(CMAKE_CL_64)
542                 # png is statically linked on win64
543                 install(
544                         FILES ${LIBDIR}/zlib/lib/zlib.dll
545                         DESTINATION ${TARGETDIR}
546                 )
547         else()
548                 #not needed since we link statically, maybe also unneeded for MinGW?
549                 if(NOT WITH_MINGW64)
550                         install(
551                                 FILES
552                                         ${LIBDIR}/zlib/lib/zlib.dll
553                                 DESTINATION ${TARGETDIR}
554                         )
555                 endif()
556         endif()
557
558         if(MSVC)
559                 install(
560                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
561                         DESTINATION ${TARGETDIR}
562                 )
563         else()
564                 #MinGW64 comes with own version. For portable builds it will probaly have to be copied to work
565                 if(NOT WITH_MINGW64)
566                         install(
567                                 FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
568                                 DESTINATION ${TARGETDIR}
569                         )
570                 elseif(WITH_MINGW64)
571                         install(
572                                 FILES 
573                                         ${LIBDIR}/binaries/libgcc_s_sjlj-1.dll
574                                         ${LIBDIR}/binaries/libwinpthread-1.dll
575                                         ${LIBDIR}/binaries/libstdc++-6.dll
576                                 DESTINATION ${TARGETDIR}
577                         )
578                         
579                         if(WITH_OPENMP)
580                                 install(
581                                         FILES 
582                                         ${LIBDIR}/binaries/libgomp-1.dll
583                                         DESTINATION ${TARGETDIR}
584                                 )
585                         endif()
586                 endif()
587         endif()
588
589         if(WITH_CODEC_FFMPEG)
590                 install(
591                         FILES
592                                 ${LIBDIR}/ffmpeg/lib/avcodec-53.dll
593                                 ${LIBDIR}/ffmpeg/lib/avformat-53.dll
594                                 ${LIBDIR}/ffmpeg/lib/avdevice-53.dll
595                                 ${LIBDIR}/ffmpeg/lib/avutil-51.dll
596                                 ${LIBDIR}/ffmpeg/lib/swscale-2.dll
597                         DESTINATION ${TARGETDIR}
598                 )
599                 if(WITH_MINGW64)
600                 install(
601                         FILES
602                                 ${LIBDIR}/ffmpeg/lib/swresample-0.dll
603                                 ${LIBDIR}/ffmpeg/lib/xvidcore.dll
604                         DESTINATION ${TARGETDIR}
605                 )
606                 endif()
607         endif()
608
609         if(WITH_CODEC_SNDFILE)
610                 install(
611                         FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
612                         DESTINATION ${TARGETDIR}
613                 )
614         endif()
615
616         if(WITH_OPENAL)
617                 install(
618                         FILES
619                                 ${LIBDIR}/openal/lib/OpenAL32.dll
620                                 ${LIBDIR}/openal/lib/wrap_oal.dll
621                         DESTINATION ${TARGETDIR}
622                 )
623         endif()
624
625         if(WITH_SDL)
626                 if(NOT CMAKE_CL_64)
627                         install(
628                                 FILES ${LIBDIR}/sdl/lib/SDL.dll
629                                 DESTINATION ${TARGETDIR}
630                         )
631                 endif()
632         endif()
633
634         if(NOT CMAKE_CL_64)
635                 install(
636                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
637                         DESTINATION ${TARGETDIR}
638                 )
639         endif()
640                 
641         install( # x86 builds can run on x64 Windows, so this is required at all times
642                 FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
643                 DESTINATION ${TARGETDIR}
644         )
645
646         if(WITH_OPENCOLORIO)
647                 set(OCIOBIN ${LIBDIR}/opencolorio/bin)
648                 if(NOT MINGW)
649                         install(
650                                 FILES
651                                         ${OCIOBIN}/OpenColorIO.dll
652                                 DESTINATION ${TARGETDIR}
653                         )
654                 else()
655                         install(
656                                 FILES
657                                         ${OCIOBIN}/libOpenColorIO.dll
658                                 DESTINATION ${TARGETDIR}
659                         )
660                 endif()
661         endif()
662
663 elseif(APPLE)
664
665         # handy install macro to exclude files, we use \$ escape for the "to"
666         # argument when calling so ${BUILD_TYPE} does not get expanded
667         macro(install_dir from to)
668                 install(
669                         DIRECTORY ${from}
670                         DESTINATION ${to}
671                         PATTERN ".svn" EXCLUDE
672                         PATTERN "*.pyc" EXCLUDE
673                         PATTERN "*.pyo" EXCLUDE
674                         PATTERN "*.orig" EXCLUDE
675                         PATTERN "*.rej" EXCLUDE
676                         PATTERN "__pycache__" EXCLUDE
677                         PATTERN "__MACOSX" EXCLUDE
678                         PATTERN ".DS_Store" EXCLUDE
679                 )
680         endmacro()
681
682         set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blender.app)
683
684         # setup Info.plist
685         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
686
687         set_target_properties(blender PROPERTIES
688                 MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist
689                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
690                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
691
692
693         # install release and app files
694         install(
695                 FILES ${BLENDER_TEXT_FILES}
696                 DESTINATION ${TARGETDIR}
697         )
698
699         install(
700                 FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo
701                 DESTINATION ${TARGETDIR}/blender.app/Contents
702         )
703
704         install_dir(
705                 ${OSX_APP_SOURCEDIR}/Contents/Resources
706                 \${TARGETDIR}/blender.app/Contents/
707         )
708
709         # python
710         if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
711                 # the python zip is first extract as part of the build process,
712                 # and then later installed as part of make install. this is much
713                 # quicker, and means we can easily exclude files on copy
714                 # Not needed for PYTHON_MODULE or WEB_PLUGIN due uses  Pyhon framework
715                 add_custom_target(
716                         extractpyzip
717                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
718
719                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
720
721                 add_custom_command(
722                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
723                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
724                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
725                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
726                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
727
728                 add_dependencies(blender extractpyzip)
729
730                 # copy extracted python files
731                 install_dir(
732                         ${CMAKE_CURRENT_BINARY_DIR}/python
733                         \${TARGETDIR_VER}
734                 )
735
736         endif()
737         
738         # install blenderplayer bundle - copy of blender.app above. re-using macros et al
739         # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
740         if(WITH_GAMEENGINE AND WITH_PLAYER)
741                 set(OSX_APP_PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blenderplayer.app)
742                 set(PLAYER_SOURCEINFO ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Info.plist)
743                 set(PLAYER_TARGETDIR_VER ${TARGETDIR}/blenderplayer.app/Contents/MacOS/${BLENDER_VERSION})
744
745
746                 # important to make a clean  install each time else old scripts get loaded.
747                 install(
748                         CODE
749                         "file(REMOVE_RECURSE ${PLAYER_TARGETDIR_VER})"
750                 )
751
752                 install(
753                         FILES ${OSX_APP_PLAYER_SOURCEDIR}/Contents/PkgInfo
754                         DESTINATION ${TARGETDIR}/blenderplayer.app/Contents
755                 )
756
757                 install_dir(
758                         ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Resources
759                         \${TARGETDIR}/blenderplayer.app/Contents/
760                 )
761
762                 # python
763                 if(WITH_PYTHON AND NOT WITH_PYTHON_FRAMEWORK)
764                         add_custom_command(
765                                 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
766                                 COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
767                                 COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
768                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
769                                 DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
770
771                         # copy extracted python files
772                         install_dir(
773                                 ${CMAKE_CURRENT_BINARY_DIR}/python
774                                 \${PLAYER_TARGETDIR_VER}
775                         )
776                 endif()
777
778         endif()
779                 
780 endif()
781
782 # -----------------------------------------------------------------------------
783 # Generic Install, for all targets
784
785
786
787 # install more files specified elsewhere
788 delayed_do_install(${TARGETDIR_VER})
789
790 unset(BLENDER_TEXT_FILES)
791
792
793 # -----------------------------------------------------------------------------
794 # Setup link libs
795
796 add_dependencies(blender makesdna)
797
798 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
799
800 list(APPEND BLENDER_LINK_LIBS
801         bf_windowmanager
802         bf_render
803 )
804
805 if(WITH_MOD_FLUID)
806         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
807 endif()
808
809 if(WITH_CYCLES)
810         list(APPEND BLENDER_LINK_LIBS
811                 cycles_render
812                 cycles_bvh
813                 cycles_device
814                 cycles_kernel
815                 cycles_util
816                 cycles_subd)
817         if(WITH_CYCLES_OSL)
818                 list(APPEND BLENDER_LINK_LIBS cycles_kernel_osl)
819         endif()
820 endif()
821
822 #if(UNIX)
823         # Sort libraries
824         set(BLENDER_SORTED_LIBS
825                 bf_windowmanager
826
827                 bf_editor_space_api
828                 bf_editor_space_action
829                 bf_editor_space_buttons
830                 bf_editor_space_console
831                 bf_editor_space_file
832                 bf_editor_space_graph
833                 bf_editor_space_image
834                 bf_editor_space_info
835                 bf_editor_space_logic
836                 bf_editor_space_nla
837                 bf_editor_space_node
838                 bf_editor_space_outliner
839                 bf_editor_space_script
840                 bf_editor_space_sequencer
841                 bf_editor_space_time
842                 bf_editor_space_userpref
843                 bf_editor_space_view3d
844                 bf_editor_space_clip
845
846                 bf_editor_text
847                 bf_editor_transform
848                 bf_editor_util
849                 bf_editor_uvedit
850                 bf_editor_curve
851                 bf_editor_gpencil
852                 bf_editor_interface
853                 bf_editor_mesh
854                 bf_editor_metaball
855                 bf_editor_object
856                 bf_editor_armature
857                 bf_editor_physics
858                 bf_editor_render
859                 bf_editor_screen
860                 bf_editor_sculpt_paint
861                 bf_editor_sound
862                 bf_editor_animation
863                 bf_editor_datafiles
864                 bf_editor_mask
865                 bf_editor_io
866
867                 bf_render
868                 bf_intern_opennl
869                 bf_python
870                 bf_python_ext
871                 bf_python_mathutils
872                 bf_python_bmesh
873                 bf_freestyle
874                 bf_ikplugin
875                 bf_modifiers
876                 bf_bmesh
877                 bf_blenkernel
878                 bf_nodes
879                 bf_gpu
880                 bf_blenloader
881                 bf_imbuf
882                 bf_blenlib
883                 bf_intern_ghost
884                 bf_intern_string
885                 bf_avi
886                 bf_imbuf_cineon
887                 bf_imbuf_openexr
888                 bf_imbuf_dds
889                 bf_collada
890                 bf_intern_bsp
891                 bf_intern_elbeem
892                 bf_intern_memutil
893                 bf_intern_guardedalloc
894                 bf_intern_ctr
895                 bf_intern_utfconv
896                 ge_blen_routines
897                 ge_converter
898                 ge_phys_dummy
899                 ge_phys_bullet
900                 bf_intern_smoke
901                 extern_minilzo
902                 extern_lzma
903                 extern_colamd
904                 ge_logic_ketsji
905                 extern_recastnavigation
906                 ge_logic
907                 ge_rasterizer
908                 ge_oglrasterizer
909                 ge_logic_expressions
910                 ge_scenegraph
911                 ge_logic_network
912                 ge_logic_ngnetwork
913                 ge_logic_loopbacknetwork
914                 bf_intern_moto
915                 extern_openjpeg
916                 extern_redcode
917                 ge_videotex
918                 bf_rna
919                 bf_dna
920                 bf_blenfont
921                 bf_intern_audaspace
922                 bf_intern_mikktspace
923                 bf_intern_dualcon
924                 bf_intern_cycles
925                 cycles_render
926                 cycles_bvh
927                 cycles_device
928                 cycles_kernel
929                 cycles_util
930                 cycles_subd
931                 bf_intern_raskter
932                 bf_intern_opencolorio
933                 extern_rangetree
934                 extern_wcwidth
935         )
936
937         if(WITH_COMPOSITOR)
938                 # added for opencl compositor
939                 list_insert_before(BLENDER_SORTED_LIBS "bf_blenkernel" "bf_compositor")
940                 list_insert_after(BLENDER_SORTED_LIBS "bf_compositor" "bf_intern_opencl")
941         endif()
942
943         if(WITH_LIBMV)
944                 list(APPEND BLENDER_SORTED_LIBS extern_libmv)
945                 list(APPEND BLENDER_SORTED_LIBS extern_ceres)
946         endif()
947
948         if(WITH_MOD_CLOTH_ELTOPO)
949                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
950         endif()
951
952         if(NOT WITH_SYSTEM_GLEW)
953                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
954         endif()
955
956         if(WITH_BINRELOC)
957                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
958         endif()
959
960         if(WITH_CXX_GUARDEDALLOC)
961                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
962         endif()
963
964         if(WITH_IK_SOLVER)
965                 list_insert_after(BLENDER_SORTED_LIBS "bf_intern_elbeem" "bf_intern_iksolver")
966         endif()
967
968         if(WITH_IK_ITASC)
969                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
970         endif()
971
972         if(WITH_CODEC_QUICKTIME)
973                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
974         endif()
975
976         if(WITH_MOD_BOOLEAN)
977                 list(APPEND BLENDER_SORTED_LIBS extern_carve)
978         endif()
979
980         if(WITH_GHOST_XDND)
981                 list(APPEND BLENDER_SORTED_LIBS extern_xdnd)
982         endif()
983
984         if(WITH_CYCLES_OSL)
985                 list_insert_after(BLENDER_SORTED_LIBS "cycles_kernel" "cycles_kernel_osl")
986         endif()
987
988         if(WITH_INTERNATIONAL)
989                 list(APPEND BLENDER_SORTED_LIBS bf_intern_locale)
990         endif()
991
992         if(WITH_BULLET)
993                 list_insert_after(BLENDER_SORTED_LIBS "bf_blenkernel" "bf_intern_rigidbody")
994         endif()
995
996         if(WITH_BULLET AND NOT WITH_SYSTEM_BULLET)
997                 list_insert_after(BLENDER_SORTED_LIBS "ge_logic_ngnetwork" "extern_bullet")
998         endif()
999
1000         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
1001                 set(REMLIB ${SORTLIB})
1002                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
1003                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
1004                                 set(REMLIB "")
1005                         endif()
1006                 endforeach()
1007                 if(REMLIB)
1008                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
1009                         list(APPEND REM_MSG ${REMLIB})
1010                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
1011                 endif()
1012         endforeach()
1013         if(REM_MSG)
1014                 list(SORT REM_MSG)
1015                 message(STATUS "Blender Skipping: (${REM_MSG})")
1016         endif()
1017         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
1018
1019         unset(SEARCHLIB)
1020         unset(SORTLIB)
1021         unset(REMLIB)
1022         unset(REM_MSG)
1023
1024 #else()
1025 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
1026 #endif()
1027
1028 setup_liblinks(blender)