e8b951f36807e8ba1a913d1bbe70897ea79555c7
[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 # helpful tip when using make
305 if("${CMAKE_GENERATOR}" MATCHES ".*Makefiles.*")
306         # message after building.
307         add_custom_command(
308                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
309                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files and scripts to ${TARGETDIR_VER}'
310         )
311 endif()
312
313
314 # -----------------------------------------------------------------------------
315 # Install Targets (Platform Specific)
316
317 if(UNIX AND NOT APPLE)
318
319         # there are a few differences between portable and system install
320         if(WITH_INSTALL_PORTABLE)
321                 install(
322                         FILES
323                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
324                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
325                                 ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
326                         DESTINATION ${TARGETDIR}
327                 )
328
329                 install(
330                         PROGRAMS
331                         ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
332                         DESTINATION ${TARGETDIR}
333                 )
334
335                 install(
336                         FILES ${BLENDER_TEXT_FILES}
337                         DESTINATION ${TARGETDIR}
338                 )
339
340         else()
341                 # main blender binary
342                 if(WITH_PYTHON_MODULE)
343                         install(
344                                 TARGETS blender
345                                 LIBRARY
346                                 DESTINATION ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages
347                         )
348                 else()
349                         install(
350                                 PROGRAMS ${TARGETDIR}/blender
351                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
352                         )
353                 endif()
354
355
356                 if(WITH_GAMEENGINE AND WITH_PLAYER)
357                         install(
358                                 PROGRAMS ${TARGETDIR}/blenderplayer
359                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
360                         )
361                 endif()
362
363                 # misc files
364                 install(
365                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
366                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
367                 )
368                 install(
369                         DIRECTORY
370                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/16x16
371                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/22x22
372                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/24x24
373                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/32x32
374                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48
375                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256
376                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor
377                         PATTERN ".svn" EXCLUDE
378                         PATTERN "*.svg" EXCLUDE
379                 )
380                 install(
381                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
382                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps
383                 )
384                 install(
385                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
386                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
387                 )
388                 install(
389                         FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
390                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
391                 )
392                 install(
393                         FILES ${BLENDER_TEXT_FILES}
394                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
395                 )
396         endif()
397
398         if(WITH_PYTHON)
399                 if(WITH_PYTHON_INSTALL)
400                         # on some platforms (like openSUSE) Python is linked
401                         # to be used from lib64 folder.
402                         # determine this from Python's libraries path
403                         if(${PYTHON_LIBPATH} MATCHES "lib64$")
404                                 set(_target_LIB "lib64")
405                         else()
406                                 set(_target_LIB "lib")
407                         endif()
408
409                         # Copy the systems python into the install directory
410                         # Scons copy in tools/Blender.py
411                         # install(CODE "message(\"copying a subset of the systems python...\")")
412                         install(
413                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
414                                 DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}
415                                 PATTERN ".svn" EXCLUDE
416                                 PATTERN "__pycache__" EXCLUDE               # * any cache *
417                                 PATTERN "distutils" EXCLUDE                 # ./distutils
418                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
419                                 PATTERN "config" EXCLUDE                    # ./config
420                                 PATTERN "config-*" EXCLUDE                  # ./config-*
421                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
422                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
423                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
424                                 PATTERN "idlelib" EXCLUDE                   # ./idlelib
425                                 PATTERN "test" EXCLUDE                      # ./test
426                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
427                                 PATTERN "turtle.py" EXCLUDE                                     # ./turtle.py
428                         )
429
430                         # # doesnt work, todo
431                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
432                         
433                         if(WITH_PYTHON_INSTALL_NUMPY)
434                                 install(
435                                         DIRECTORY ${PYTHON_NUMPY_PATH}/numpy
436                                         DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/site-packages
437                                         PATTERN ".svn" EXCLUDE
438                                         PATTERN "__pycache__" EXCLUDE           # * any cache *
439                                         PATTERN "*.pyc" EXCLUDE                 # * any cache *
440                                         PATTERN "*.pyo" EXCLUDE                 # * any cache *
441                                         PATTERN "distutils" EXCLUDE             # ./distutils
442                                         PATTERN "oldnumeric" EXCLUDE            # ./oldnumeric
443                                         PATTERN "doc" EXCLUDE                   # ./doc
444                                         PATTERN "tests" EXCLUDE                 # ./tests
445                                         PATTERN "f2py" EXCLUDE                  # ./f2py - fortran/python interface code, not fun for blender devs.
446                                         PATTERN "include" EXCLUDE               # include dirs all over, we wont use NumPy/CAPI
447                                         PATTERN "*.h" EXCLUDE                   # some includes are not in include dirs
448                                         PATTERN "*.a" EXCLUDE                   # ./core/lib/libnpymath.a - for linking, we dont need.
449                                 )
450                         endif()
451                         
452                         unset(_target_LIB)
453                         
454                 endif()
455         endif()
456 elseif(WIN32)
457
458         install(
459                 FILES ${BLENDER_TEXT_FILES}
460                 DESTINATION ${TARGETDIR}
461         )
462
463         if(WITH_INTERNATIONAL AND (NOT WITH_MINGW64))
464                 install(
465                         FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
466                         DESTINATION ${TARGETDIR}
467                 )
468
469                 if(NOT CMAKE_CL_64)
470                         install(
471                                 FILES ${LIBDIR}/iconv/lib/iconv.dll
472                                 DESTINATION ${TARGETDIR}
473                         )
474                 endif()
475         endif()
476
477         if(WITH_PYTHON)
478                 set_lib_path(PYLIB "python/lib")
479                 install(
480                         FILES ${PYLIB}/python32.dll
481                         DESTINATION ${TARGETDIR}
482                         CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
483                 )
484
485                 install(
486                         FILES ${PYLIB}/python32_d.dll
487                         DESTINATION ${TARGETDIR}
488                         CONFIGURATIONS Debug
489                 )
490
491                 if(WITH_PYTHON_INSTALL)
492                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
493
494                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
495                         install(
496                                 CODE
497                                 "
498                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
499                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\")
500                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\")
501                                 message(\"done creating dir\")
502                                 "
503                         )
504
505                         install(
506                                 CODE
507                                 "
508                                 if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
509                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
510                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32_d.tar.gz\")
511                                 else()
512                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
513                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
514                                 endif()
515                                 "
516                         )
517
518                         # doesnt work, todo
519                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
520                 endif()
521         endif()
522
523         if(CMAKE_CL_64)
524                 # gettext and png are statically linked on win64
525                 install(
526                         FILES ${LIBDIR}/zlib/lib/zlib.dll
527                         DESTINATION ${TARGETDIR}
528                 )
529         else()
530                 #not needed since we link statically, maybe also unneeded for MinGW?
531                 if(NOT WITH_MINGW64)
532                         install(
533                                 FILES
534                                         ${LIBDIR}/zlib/lib/zlib.dll
535                                 DESTINATION ${TARGETDIR}
536                         )
537                 endif()
538         endif()
539
540         if(MSVC)
541                 install(
542                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
543                         DESTINATION ${TARGETDIR}
544                 )
545         else()
546                 #MinGW64 comes with own version. For portable builds it will probaly have to be copied to work
547                 if(NOT WITH_MINGW64)
548                         install(
549                                 FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
550                                 DESTINATION ${TARGETDIR}
551                         )
552                 elseif(WITH_MINGW64)
553                         install(
554                                 FILES ${LIBDIR}/binaries/pthreadGC2-w64.dll
555                                 DESTINATION ${TARGETDIR}
556                         )
557                 endif()
558         endif()
559
560         if(WITH_CODEC_FFMPEG)
561                 install(
562                         FILES
563                                 ${LIBDIR}/ffmpeg/lib/avcodec-53.dll
564                                 ${LIBDIR}/ffmpeg/lib/avformat-53.dll
565                                 ${LIBDIR}/ffmpeg/lib/avdevice-53.dll
566                                 ${LIBDIR}/ffmpeg/lib/avutil-51.dll
567                                 ${LIBDIR}/ffmpeg/lib/swscale-2.dll
568                         DESTINATION ${TARGETDIR}
569                 )
570                 if(WITH_MINGW64)
571                 install(
572                         FILES
573                                 ${LIBDIR}/ffmpeg/lib/swresample-0.dll
574                                 ${LIBDIR}/ffmpeg/lib/xvidcore.dll
575                         DESTINATION ${TARGETDIR}
576                 )
577                 endif()
578         endif()
579
580         if(WITH_CODEC_SNDFILE)
581                 install(
582                         FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
583                         DESTINATION ${TARGETDIR}
584                 )
585         endif()
586
587         if(WITH_OPENAL)
588                 install(
589                         FILES
590                                 ${LIBDIR}/openal/lib/OpenAL32.dll
591                                 ${LIBDIR}/openal/lib/wrap_oal.dll
592                         DESTINATION ${TARGETDIR}
593                 )
594         endif()
595
596         if(WITH_SDL)
597                 if(NOT CMAKE_CL_64)
598                         install(
599                                 FILES ${LIBDIR}/sdl/lib/SDL.dll
600                                 DESTINATION ${TARGETDIR}
601                         )
602                 endif()
603         endif()
604
605         if(NOT CMAKE_CL_64)
606                 install(
607                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
608                         DESTINATION ${TARGETDIR}
609                 )
610         endif()
611                 
612         install( # x86 builds can run on x64 Windows, so this is required at all times
613                 FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
614                 DESTINATION ${TARGETDIR}
615         )       
616
617         if(WITH_OPENIMAGEIO)
618                 if(NOT MINGW)
619                         set_lib_path(OIIOBIN "openimageio/bin")
620                         install(
621                                 FILES
622                                         ${OIIOBIN}/OpenImageIO.dll
623                                 DESTINATION ${TARGETDIR}
624                         )
625                 endif()
626         endif()
627
628 elseif(APPLE)
629
630         # handy install macro to exclude files, we use \$ escape for the "to"
631         # argument when calling so ${BUILD_TYPE} does not get expanded
632         macro(install_dir from to)
633                 install(
634                         DIRECTORY ${from}
635                         DESTINATION ${to}
636                         PATTERN ".svn" EXCLUDE
637                         PATTERN "*.pyc" EXCLUDE
638                         PATTERN "*.pyo" EXCLUDE
639                         PATTERN "*.orig" EXCLUDE
640                         PATTERN "*.rej" EXCLUDE
641                         PATTERN "__pycache__" EXCLUDE
642                         PATTERN "__MACOSX" EXCLUDE
643                         PATTERN ".DS_Store" EXCLUDE
644                 )
645         endmacro()
646
647         set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
648
649         # setup Info.plist
650         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
651
652         set_target_properties(blender PROPERTIES
653                 MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist
654                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
655                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
656
657
658         # install release and app files
659         install(
660                 FILES ${BLENDER_TEXT_FILES}
661                 DESTINATION ${TARGETDIR}
662         )
663
664         install(
665                 FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo
666                 DESTINATION ${TARGETDIR}/blender.app/Contents
667         )
668
669         install_dir(
670                 ${OSX_APP_SOURCEDIR}/Contents/Resources
671                 \${TARGETDIR}/blender.app/Contents/
672         )
673
674         # python
675         if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE)
676                 # the python zip is first extract as part of the build process,
677                 # and then later installed as part of make install. this is much
678                 # quicker, and means we can easily exclude files on copy
679                 # Not needed for PYTHON_MODULE or WEB_PLUGIN due uses  Pyhon framework
680                 add_custom_target(
681                         extractpyzip
682                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
683
684                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
685
686                 add_custom_command(
687                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
688                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
689                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
690                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
691                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
692
693                 add_dependencies(blender extractpyzip)
694
695                 # copy extracted python files
696                 install_dir(
697                         ${CMAKE_CURRENT_BINARY_DIR}/python
698                         \${TARGETDIR_VER}
699                 )
700
701         endif()
702
703         # install blenderplayer bundle - copy of blender.app above. re-using macros et al
704         # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
705         if(WITH_GAMEENGINE AND WITH_PLAYER)
706                 set(OSX_APP_PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blenderplayer.app)
707                 set(PLAYER_SOURCEINFO ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Info.plist)
708                 set(PLAYER_TARGETDIR_VER ${TARGETDIR}/blenderplayer.app/Contents/MacOS/${BLENDER_VERSION})
709
710
711                 # important to make a clean  install each time else old scripts get loaded.
712                 install(
713                         CODE
714                         "file(REMOVE_RECURSE ${PLAYER_TARGETDIR_VER})"
715                 )
716
717                 install(
718                         FILES ${OSX_APP_PLAYER_SOURCEDIR}/Contents/PkgInfo
719                         DESTINATION ${TARGETDIR}/blenderplayer.app/Contents
720                 )
721
722                 install_dir(
723                         ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Resources
724                         \${TARGETDIR}/blenderplayer.app/Contents/
725                 )
726
727                 # python
728                 if(WITH_PYTHON)
729                         add_custom_command(
730                                 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
731                                 COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
732                                 COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
733                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
734                                 DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
735
736                         # copy extracted python files
737                         install_dir(
738                                 ${CMAKE_CURRENT_BINARY_DIR}/python
739                                 \${PLAYER_TARGETDIR_VER}
740                         )
741                 endif()
742
743         endif()
744 endif()
745
746 # -----------------------------------------------------------------------------
747 # Generic Install, for all targets
748
749
750
751 # install more files specified elsewhere
752 delayed_do_install(${TARGETDIR_VER})
753
754 unset(BLENDER_TEXT_FILES)
755
756
757 # -----------------------------------------------------------------------------
758 # Setup link libs
759
760 add_dependencies(blender makesdna)
761
762 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
763
764 set(BLENDER_LINK_LIBS
765         ${BLENDER_LINK_LIBS}
766         bf_windowmanager
767         bf_render
768 )
769
770 if(WITH_MOD_FLUID)
771         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
772 endif()
773
774 if(WITH_CYCLES)
775         list(APPEND BLENDER_LINK_LIBS
776                 cycles_render
777                 cycles_bvh
778                 cycles_device
779                 cycles_kernel
780                 cycles_util
781                 cycles_subd)
782 endif()
783
784 #if(UNIX)
785         # Sort libraries
786         set(BLENDER_SORTED_LIBS
787                 bf_windowmanager
788
789                 bf_editor_space_api
790                 bf_editor_space_action
791                 bf_editor_space_buttons
792                 bf_editor_space_console
793                 bf_editor_space_file
794                 bf_editor_space_graph
795                 bf_editor_space_image
796                 bf_editor_space_info
797                 bf_editor_space_logic
798                 bf_editor_space_nla
799                 bf_editor_space_node
800                 bf_editor_space_outliner
801                 bf_editor_space_script
802                 bf_editor_space_sequencer
803                 bf_editor_space_time
804                 bf_editor_space_userpref
805                 bf_editor_space_view3d
806                 bf_editor_space_clip
807
808                 bf_editor_text
809                 bf_editor_transform
810                 bf_editor_util
811                 bf_editor_uvedit
812                 bf_editor_curve
813                 bf_editor_armature
814                 bf_editor_gpencil
815                 bf_editor_interface
816                 bf_editor_mesh
817                 bf_editor_metaball
818                 bf_editor_object
819                 bf_editor_physics
820                 bf_editor_render
821                 bf_editor_screen
822                 bf_editor_sculpt_paint
823                 bf_editor_sound
824                 bf_editor_animation
825                 bf_editor_datafiles
826                 bf_editor_mask
827                 bf_editor_io
828
829                 bf_render
830                 bf_intern_opennl
831                 bf_python
832                 bf_python_ext
833                 bf_python_mathutils
834                 bf_python_bmesh
835                 bf_ikplugin
836                 bf_modifiers
837                 bf_bmesh
838                 bf_blenkernel
839                 bf_nodes
840                 bf_gpu
841                 bf_blenloader
842                 bf_imbuf
843                 bf_blenlib
844                 bf_intern_ghost
845                 bf_intern_string
846                 bf_avi
847                 bf_imbuf_cineon
848                 bf_imbuf_openexr
849                 bf_imbuf_dds
850                 bf_collada
851                 bf_intern_bsp
852                 bf_intern_bop
853                 bf_intern_decimate
854                 bf_intern_elbeem
855                 bf_intern_ik
856                 bf_intern_memutil
857                 bf_intern_guardedalloc
858                 bf_intern_ctr
859                 bf_intern_utfconv
860                 ge_blen_routines
861                 ge_converter
862                 ge_phys_dummy
863                 ge_phys_bullet
864                 bf_intern_smoke
865                 extern_minilzo
866                 extern_lzma
867                 extern_colamd
868                 ge_logic_ketsji
869                 extern_recastnavigation
870                 ge_phys_common
871                 ge_logic
872                 ge_rasterizer
873                 ge_oglrasterizer
874                 ge_logic_expressions
875                 ge_scenegraph
876                 ge_logic_network
877                 ge_logic_ngnetwork
878                 extern_bullet
879                 ge_logic_loopbacknetwork
880                 bf_intern_moto
881                 extern_openjpeg
882                 extern_redcode
883                 ge_videotex
884                 bf_rna
885                 bf_dna
886                 bf_blenfont
887                 bf_intern_audaspace
888                 bf_intern_mikktspace
889                 bf_intern_dualcon
890                 bf_intern_cycles
891                 cycles_render
892                 cycles_bvh
893                 cycles_device
894                 cycles_kernel
895                 cycles_util
896                 cycles_subd
897                 bf_compositor #added for opencl compositor
898                 bf_opencl #added for opencl compositor
899                 bf_intern_raskter
900         )
901
902         if(WITH_LIBMV)
903                 list(APPEND BLENDER_SORTED_LIBS extern_libmv)
904                 list(APPEND BLENDER_SORTED_LIBS extern_ceres)
905         endif()
906
907         if(WITH_MOD_CLOTH_ELTOPO)
908                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
909         endif()
910
911         if(WITH_BUILTIN_GLEW)
912                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
913         endif()
914
915         if(WITH_BINRELOC)
916                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
917         endif()
918
919         if(WITH_CXX_GUARDEDALLOC)
920                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
921         endif()
922
923         if(WITH_IK_ITASC)
924                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
925         endif()
926
927         if(WITH_CODEC_QUICKTIME)
928                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
929         endif()
930
931         if(WITH_CARVE)
932                 list(APPEND BLENDER_SORTED_LIBS extern_carve)
933         endif()
934
935         if(WITH_GHOST_XDND)
936                 list(APPEND BLENDER_SORTED_LIBS extern_xdnd)
937         endif()
938
939         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
940                 set(REMLIB ${SORTLIB})
941                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
942                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
943                                 set(REMLIB "")
944                         endif()
945                 endforeach()
946                 if(REMLIB)
947                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
948                         list(APPEND REM_MSG ${REMLIB})
949                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
950                 endif()
951         endforeach()
952         if(REM_MSG)
953                 list(SORT REM_MSG)
954                 message(STATUS "Blender Skipping: (${REM_MSG})")
955         endif()
956         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
957
958         unset(SEARCHLIB)
959         unset(SORTLIB)
960         unset(REMLIB)
961         unset(REM_MSG)
962
963 #else()
964 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
965 #endif()
966
967 setup_liblinks(blender)