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