Cycles: svn merge -r36352:36495 https://svn.blender.org/svnroot/bf-blender/trunk...
[blender.git] / source / creator / CMakeLists.txt
1 # -*- mode: cmake; indent-tabs-mode: t; -*-
2 # $Id$
3 # ***** BEGIN GPL LICENSE BLOCK *****
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #
19 # The Original Code is Copyright (C) 2006, Blender Foundation
20 # All rights reserved.
21 #
22 # The Original Code is: all of this file.
23 #
24 # Contributor(s): Jacques Beaurain.
25 #
26 # ***** END GPL LICENSE BLOCK *****
27
28 # So BUILDINFO and BLENDERPATH strings are automatically quoted
29 cmake_policy(SET CMP0005 NEW)
30
31 setup_libdirs()
32
33 blender_include_dirs(
34         ../../intern/guardedalloc
35         ../blender/blenlib
36         ../blender/blenkernel
37         ../blender/blenloader
38         ../blender/editors/include
39         ../blender/makesrna
40         ../blender/imbuf
41         ../blender/render/extern/include
42         ../blender/makesdna
43         ../blender/gpu
44         ../blender/windowmanager
45 )
46
47 if(WITH_CODEC_QUICKTIME)
48         add_definitions(-DWITH_QUICKTIME)
49 endif()
50
51 if(WITH_IMAGE_OPENEXR)
52         add_definitions(-DWITH_OPENEXR)
53 endif()
54
55 if(WITH_IMAGE_OPENJPEG)
56         add_definitions(-DWITH_OPENJPEG)
57 endif()
58
59 if(WITH_IMAGE_TIFF)
60         add_definitions(-DWITH_TIFF)
61 endif()
62
63 if(WITH_IMAGE_DDS)
64         add_definitions(-DWITH_DDS)
65 endif()
66
67 if(WITH_IMAGE_CINEON)
68         add_definitions(-DWITH_CINEON)
69 endif()
70
71 if(WITH_IMAGE_HDR)
72         add_definitions(-DWITH_HDR)
73 endif()
74
75 if(WITH_PYTHON)
76         blender_include_dirs(../blender/python)
77         add_definitions(-DWITH_PYTHON)
78
79         if(WITH_PYTHON_SECURITY)
80                 add_definitions(-DWITH_PYTHON_SECURITY)
81         endif()
82 endif()
83
84 if(WITH_GAMEENGINE)
85         blender_include_dirs(
86                 ../kernel/gen_messaging
87                 ../kernel/gen_system
88         )
89
90         add_definitions(-DWITH_GAMEENGINE)
91 endif()
92
93 if(NOT WITH_SDL)
94         add_definitions(-DDISABLE_SDL)
95 endif()
96
97 if(WITH_BINRELOC)
98         add_definitions(-DWITH_BINRELOC)
99         blender_include_dirs(${BINRELOC_INC})
100 endif()
101
102 # Setup the exe sources and buildinfo
103 set(SRC
104         creator.c
105 )
106
107 # MSVC 2010 gives linking errors with the manifest
108 if(WIN32 AND NOT UNIX)
109         string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
110         string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
111         string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
112         if(MINGW)
113                 add_definitions(
114                         -DWINDRES
115                         -DBLEN_VER_RC_STR_M=${BLENDER_VERSION}
116                         -DBLEN_VER_RC_1=${bver1}
117                         -DBLEN_VER_RC_2=${bver2}
118                         -DBLEN_VER_RC_3=${bver3}
119                         -DBLEN_VER_RC_4=0
120                 )
121         else()
122                 add_definitions(
123                         -DBLEN_VER_RC_STR=${BLENDER_VERSION}
124                         -DBLEN_VER_RC_1=${bver1}
125                         -DBLEN_VER_RC_2=${bver2}
126                         -DBLEN_VER_RC_3=${bver3}
127                         -DBLEN_VER_RC_4=0
128                 )
129         endif()
130         
131
132         list(APPEND SRC
133                 ../icons/winblender.rc
134         )
135 endif()
136
137 if(WITH_BUILDINFO)
138         # --------------------------------------------------------------------------
139         # These defines could all be moved into the header below
140         string(REPLACE " " "\ " BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}")
141         string(REPLACE " " "\ " BUILDINFO_CXXFLAGS "${CMAKE_CXX_FLAGS}")
142         string(REPLACE " " "\ " BUILDINFO_LINKFLAGS "${PLATFORM_LINKFLAGS}")
143         add_definitions(
144                 # # define in header now, else these get out of date on rebuilds.
145                 # -DBUILD_DATE="${BUILD_DATE}"
146                 # -DBUILD_TIME="${BUILD_TIME}"
147                 # -DBUILD_REV="${BUILD_REV}"
148                 -DWITH_BUILDINFO_HEADER # alternative to lines above
149                 -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
150                 -DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
151                 -DBUILD_CFLAGS="${BUILDINFO_CFLAGS}"
152                 -DBUILD_CXXFLAGS="${BUILDINFO_CXXFLAGS}"
153                 -DBUILD_LINKFLAGS="${BUILDINFO_LINKFLAGS}"
154                 -DBUILD_SYSTEM="CMake"
155         )
156
157         # --------------------------------------------------------------------------
158         # write header for values that change each build
159         # note, generaed file is in build dir's source/creator
160         #       except when used as an include path.
161
162         # include the output directory, where the buildinfo.h file is generated
163         include_directories(${CMAKE_BINARY_DIR}/source/creator)
164
165         # a custom target that is always built
166         add_custom_target(buildinfo ALL
167                 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h)
168
169         # creates svnheader.h using cmake script
170         add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h
171                 COMMAND ${CMAKE_COMMAND}
172                 -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
173                 -P ${CMAKE_SOURCE_DIR}/build_files/cmake/buildinfo.cmake)
174
175         # buildinfo.h is a generated file
176         set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h
177                 PROPERTIES GENERATED TRUE
178                 HEADER_FILE_ONLY TRUE)
179
180         # add deps below, after adding blender
181         # -------------- done with header values.
182
183         list(APPEND SRC
184                 buildinfo.c
185         )
186 endif()
187
188 # message(STATUS "Configuring blender")
189 if(WITH_PYTHON_MODULE)
190         add_definitions(-DWITH_PYTHON_MODULE)
191
192         # creates ./bin/bpy.so which can be imported as a python module.
193         add_library(blender SHARED ${SRC})
194         set_target_properties(
195                 blender
196                 PROPERTIES
197                          PREFIX ""
198                          OUTPUT_NAME bpy
199                          LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/
200                          RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/  # only needed on windows
201         )
202         
203         if(WIN32)
204                 # python modules use this
205                 set_target_properties(
206                         blender
207                         PROPERTIES
208                                  SUFFIX ".pyd"
209                 )       
210         endif()
211         
212 else()
213         add_executable(blender ${EXETYPE} ${SRC})
214 endif()
215
216 if(WITH_BUILDINFO)
217         # explicitly say that the executable depends on the buildinfo
218         add_dependencies(blender buildinfo)
219 endif()
220
221 # Post build steps for bundling/packaging.
222
223
224 if(MSVC_IDE)
225         # ${CMAKE_CFG_INTDIR} should replace \${BUILD_TYPE} when using add_command
226         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE})
227 elseif(APPLE)
228         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE})
229 else()
230         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH})
231 endif()
232
233 # headers
234 install(
235         FILES
236         ${CMAKE_SOURCE_DIR}/source/blender/makesrna/RNA_access.h
237         ${CMAKE_SOURCE_DIR}/source/blender/makesrna/RNA_types.h
238         ${CMAKE_BINARY_DIR}/source/blender/makesrna/intern/RNA_blender.h
239         ${CMAKE_BINARY_DIR}/source/blender/makesrna/intern/RNA_blender_cpp.h
240         ${CMAKE_SOURCE_DIR}/intern/guardedalloc/MEM_sys_types.h
241         ${CMAKE_SOURCE_DIR}/intern/guardedalloc/MEM_guardedalloc.h
242         ${CMAKE_SOURCE_DIR}/source/blender/blenloader/BLO_sys_types.h
243         ${CMAKE_SOURCE_DIR}/source/blender/makesdna/DNA_listBase.h
244         DESTINATION ${INCLUDE_OUTPUT_PATH})
245
246 # install target
247 if(UNIX AND NOT APPLE)
248
249         if(WITH_INSTALL_PORTABLE)
250                 set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
251         else()
252                 set(TARGETDIR_VER ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION})
253         endif()
254
255         # important to make a clean  install each time
256         # else old scripts get loaded.
257         install(
258                 CODE
259                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
260         )
261
262         # message after building.
263         add_custom_command(
264                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
265                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${TARGETDIR_VER}'
266         )
267
268         # there are a few differences between portable and system install
269         if(WITH_INSTALL_PORTABLE)
270                 install(
271                         FILES
272                         ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
273                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
274                         ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
275                         DESTINATION ${TARGETDIR}
276                 )
277
278                 install(
279                         PROGRAMS
280                         ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
281                         DESTINATION ${TARGETDIR}
282                 )
283
284                 install(
285                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
286                         DESTINATION ${TARGETDIR}
287                         PATTERN ".svn" EXCLUDE
288                 )
289
290         else()
291                 # main blender binary
292                 install(
293                         PROGRAMS ${TARGETDIR}/blender
294                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
295                 )
296
297                 if(WITH_GAMEENGINE AND WITH_PLAYER)
298                         install(
299                                 PROGRAMS ${TARGETDIR}/blenderplayer
300                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
301                         )
302                 endif()
303
304                 # misc files
305                 install(
306                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
307                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
308                 )
309                 install(
310                         DIRECTORY
311                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/16x16
312                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/22x22
313                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/24x24
314                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/32x32
315                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48
316                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256
317                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/
318                         PATTERN ".svn" EXCLUDE
319                         PATTERN "*.svg" EXCLUDE
320                 )
321                 install(
322                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
323                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps
324                 )
325                 install(
326                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
327                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
328                 )
329                 install(
330                         FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
331                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
332                 )
333                 install(
334                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
335                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
336                         PATTERN ".svn" EXCLUDE
337                 )
338         endif()
339
340         install(
341                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
342                 DESTINATION ${TARGETDIR_VER}/config
343         )
344
345         if(WITH_INTERNATIONAL)
346                 install(
347                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
348                         DESTINATION ${TARGETDIR_VER}/config
349                 )
350
351                 install(
352                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
353                         DESTINATION ${TARGETDIR_VER}/datafiles/
354                         PATTERN ".svn" EXCLUDE
355                 )
356         endif()
357
358                 # plugins in blender 2.5 don't work at the moment.
359                 #
360                 # install(
361                 #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
362                 #       DESTINATION ${TARGETDIR_VER}/
363                 #       PATTERN ".svn" EXCLUDE
364                 # )
365
366         if(WITH_PYTHON)
367                 # install(CODE "message(\"copying blender scripts...\")")
368                 install(
369                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
370                         DESTINATION ${TARGETDIR_VER}/
371                         PATTERN ".svn" EXCLUDE
372                         PATTERN "__pycache__" EXCLUDE
373                 )
374
375                 if(WITH_PYTHON_INSTALL)
376                         # Copy the systems python into the install directory
377                         # Scons copy in tools/Blender.py
378                         # install(CODE "message(\"copying a subset of the systems python...\")")
379                         install(
380                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
381                                 DESTINATION ${TARGETDIR_VER}/python/lib/
382                                 PATTERN ".svn" EXCLUDE
383                                 PATTERN "__pycache__" EXCLUDE               # ./distutils
384                                 PATTERN "distutils" EXCLUDE                 # ./distutils
385                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
386                                 PATTERN "config" EXCLUDE                    # ./config
387                                 PATTERN "config-*" EXCLUDE                  # ./config-*
388                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
389                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
390                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
391                                 PATTERN "test" EXCLUDE                      # ./test
392                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
393                         )
394
395                         # # doesnt work, todo
396                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
397                 endif()
398         endif()
399 elseif(WIN32)
400
401         set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
402
403         install(  # same as linux!, deduplicate
404                 CODE
405                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
406         )
407
408         install(  # same as linux!, deduplicate
409                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
410                 DESTINATION ${TARGETDIR}/
411                 PATTERN ".svn" EXCLUDE
412         )
413
414         install(  # same as linux!, deduplicate
415                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
416                 DESTINATION ${TARGETDIR_VER}/config
417         )
418
419         if(WITH_INTERNATIONAL) # same as linux!, deduplicate
420                 install(
421                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
422                         DESTINATION ${TARGETDIR_VER}/config
423                 )
424                 install(
425                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
426                         DESTINATION ${TARGETDIR_VER}/datafiles/
427                         PATTERN ".svn" EXCLUDE
428                 )
429
430                 if(NOT CMAKE_CL_64)
431                         install(
432                                 FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
433                                 DESTINATION ${TARGETDIR}/
434                         )
435
436                         install(
437                                 FILES ${LIBDIR}/iconv/lib/iconv.dll
438                                 DESTINATION ${TARGETDIR}/
439                         )
440                 endif()
441         endif()
442
443         install( # same as linux!, deduplicate
444                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/
445                 DESTINATION ${TARGETDIR_VER}/datafiles/locale
446                 PATTERN ".svn" EXCLUDE
447         )
448
449         # plugins in blender 2.5 don't work at the moment.
450         #
451         # install(
452         #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
453         #       DESTINATION ${TARGETDIR_VER}/
454         #       PATTERN ".svn" EXCLUDE
455         # )
456
457         if(WITH_PYTHON)
458                 # install(CODE "message(\"copying blender scripts...\")")
459                 install(  # same as linux!, deduplicate
460                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
461                         DESTINATION ${TARGETDIR_VER}/
462                         PATTERN ".svn" EXCLUDE
463                         PATTERN "__pycache__" EXCLUDE
464                 )
465
466                 # TODO, multiple targets?
467                 install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS Release)
468                 install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS RelWithDebInfo)
469                 install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS MinSizeRel)
470
471                 install(
472                         FILES ${LIBDIR}/python/lib/python32_d.dll
473                         DESTINATION ${TARGETDIR}/
474                         CONFIGURATIONS Debug
475                 )
476
477                 if(WITH_PYTHON_INSTALL)
478                         #~ # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
479
480                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
481                         install(CODE "
482                         message(\"creating ${TARGETDIR_VER}/python/lib\")
483                         file(MAKE_DIRECTORY ${TARGETDIR_VER}/python/)
484                         file(MAKE_DIRECTORY ${TARGETDIR_VER}/python/lib/)
485                         message(\"done creating dir\")
486                         ")
487
488                         install(
489                                 CODE
490                                 "
491                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
492                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
493                                 "
494                                 CONFIGURATIONS Release
495                         )
496                         install(
497                                 CODE
498                                 "
499                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
500                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
501                                 "
502                                 CONFIGURATIONS RelWithDebInfo
503                         )
504                         install(
505                                 CODE
506                                 "
507                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
508                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
509                                 "
510                                 CONFIGURATIONS MinSizeRel
511                         )
512                         install(
513                                 CODE
514                                 "
515                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
516                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32_d.tar.gz\")
517                                 "
518                                 CONFIGURATIONS Debug
519                         )
520
521                         # doesnt work, todo
522                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
523                 endif()
524         endif()
525
526         if(CMAKE_CL_64)
527                 # gettext and png are statically linked on win64
528                 install(
529                         FILES ${LIBDIR}/zlib/lib/zlib.dll
530                         DESTINATION ${TARGETDIR}/
531                 )
532         else()
533                 install(
534                         FILES
535                         ${LIBDIR}/png/lib/libpng.dll
536                         ${LIBDIR}/zlib/lib/zlib.dll
537                         DESTINATION ${TARGETDIR}/
538                 )
539         endif()
540
541         if(MSVC)
542                 install(
543                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
544                         DESTINATION ${TARGETDIR}/
545                 )
546         else()
547                 install(
548                         FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
549                         DESTINATION ${TARGETDIR}/
550                 )
551         endif()
552
553         if(WITH_CODEC_FFMPEG)
554                 install(
555                         FILES
556                         ${LIBDIR}/ffmpeg/lib/avcodec-52.dll
557                         ${LIBDIR}/ffmpeg/lib/avformat-52.dll
558                         ${LIBDIR}/ffmpeg/lib/avdevice-52.dll
559                         ${LIBDIR}/ffmpeg/lib/avutil-50.dll
560                         ${LIBDIR}/ffmpeg/lib/swscale-0.dll
561                         DESTINATION ${TARGETDIR}/
562                 )
563
564         endif()
565
566         if(WITH_CODEC_SNDFILE)
567                 install(
568                         FILES
569                         ${LIBDIR}/sndfile/lib/libsndfile-1.dll
570                         DESTINATION ${TARGETDIR}/
571                 )
572         endif()
573
574         if(WITH_OPENAL)
575                 install(
576                         FILES
577                         ${LIBDIR}/openal/lib/OpenAL32.dll
578                         ${LIBDIR}/openal/lib/wrap_oal.dll
579                         DESTINATION ${TARGETDIR}/
580                 )
581         endif()
582
583         if(WITH_SDL)
584                 if(NOT CMAKE_CL_64)
585                         install(
586                                 FILES
587                                 ${LIBDIR}/sdl/lib/SDL.dll
588                                 DESTINATION ${TARGETDIR}/
589                         )
590                 endif()
591         endif()
592
593     if(NOT CMAKE_CL_64)
594                 install(
595                         FILES
596                 ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
597                 DESTINATION ${TARGETDIR}/
598             )
599     else()
600                 install(
601                         FILES
602                 ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
603                 DESTINATION ${TARGETDIR}/
604             )
605     endif()
606
607 elseif(APPLE)
608         set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
609         set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
610         set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
611
612         # setup Info.plist
613         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
614
615         set_target_properties(blender PROPERTIES
616                 MACOSX_BUNDLE_INFO_PLIST ${SOURCEINFO}
617                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
618                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
619
620         # important to make a clean  install each time else old scripts get loaded.
621         install(
622                 CODE
623                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
624         )
625
626         # message after building.
627         add_custom_command(
628                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
629                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${TARGETDIR_VER}'
630         )
631
632         # handy install macro to exclude files, we use \$ escape for the "to"
633         # argument when calling so ${BUILD_TYPE} does not get expanded
634         macro(install_dir from to)
635                 install(
636                         DIRECTORY ${from}
637                         DESTINATION ${to}
638                         PATTERN ".svn" EXCLUDE
639                         PATTERN "*.pyc" EXCLUDE
640                         PATTERN "*.pyo" EXCLUDE
641                         PATTERN "*.orig" EXCLUDE
642                         PATTERN "*.rej" EXCLUDE
643                         PATTERN "__pycache__" EXCLUDE
644                         PATTERN "__MACOSX" EXCLUDE
645                         PATTERN ".DS_Store" EXCLUDE
646                 )
647         endmacro()
648
649         # install release and app files
650         install_dir(
651                 ${CMAKE_SOURCE_DIR}/release/text/
652                 \${TARGETDIR}
653         )
654
655         install(
656                 FILES ${SOURCEDIR}/Contents/PkgInfo
657                 DESTINATION ${TARGETDIR}/blender.app/Contents/
658         )
659
660         install_dir(
661                 ${SOURCEDIR}/Contents/Resources
662                 \${TARGETDIR}/blender.app/Contents/
663         )
664
665         install(
666                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
667                 DESTINATION ${TARGETDIR_VER}/datafiles
668         )
669
670         # localization
671         if(WITH_INTERNATIONAL)
672                 install(
673                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
674                         DESTINATION ${TARGETDIR_VER}/datafiles
675                 )
676
677                 install_dir(
678                         ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/
679                         \${TARGETDIR_VER}/datafiles/locale
680                 )
681         endif()
682
683         # python
684         if(WITH_PYTHON)
685                 # the python zip is first extract as part of the build process,
686                 # and then later installed as part of make install. this is much
687                 # quicker, and means we can easily exclude files on copy
688                 add_custom_target(
689                         extractpyzip
690                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
691
692                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
693                         
694                 add_custom_command(
695                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
696                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
697                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
698                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
699                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
700                 
701                 add_dependencies(blender extractpyzip)
702
703                 # copy extracted python files
704                 install_dir(
705                         ${CMAKE_CURRENT_BINARY_DIR}/python
706                         \${TARGETDIR_VER}
707                 )
708
709                 # copy scripts
710                 install_dir(
711                         ${CMAKE_SOURCE_DIR}/release/scripts
712                         \${TARGETDIR_VER}
713                 )
714         endif()
715 endif()
716
717 add_dependencies(blender makesdna)
718
719 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
720
721 set(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
722
723 if(WITH_MOD_FLUID)
724         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
725 endif()
726
727
728 #if(UNIX)
729         # Sort libraries
730         set(BLENDER_SORTED_LIBS
731                 bf_windowmanager
732
733                 bf_editor_space_api
734                 bf_editor_space_action
735                 bf_editor_space_buttons
736                 bf_editor_space_console
737                 bf_editor_space_file
738                 bf_editor_space_graph
739                 bf_editor_space_image
740                 bf_editor_space_info
741                 bf_editor_space_logic
742                 bf_editor_space_nla
743                 bf_editor_space_node
744                 bf_editor_space_outliner
745                 bf_editor_space_script
746                 bf_editor_space_sequencer
747                 bf_editor_space_sound
748                 bf_editor_space_time
749                 bf_editor_space_userpref
750                 bf_editor_space_view3d
751
752                 bf_editor_text
753                 bf_editor_transform
754                 bf_editor_util
755                 bf_editor_uvedit
756                 bf_editor_curve
757                 bf_editor_armature
758                 bf_editor_gpencil
759                 bf_editor_interface
760                 bf_editor_mesh
761                 bf_editor_metaball
762                 bf_editor_object
763                 bf_editor_physics
764                 bf_editor_render
765                 bf_editor_screen
766                 bf_editor_sculpt_paint
767                 bf_editor_sound
768                 bf_editor_animation
769                 bf_editor_datafiles
770
771                 bf_render
772                 bf_intern_opennl
773                 bf_python
774                 bf_python_ext
775                 bf_ikplugin
776                 bf_modifiers
777                 bf_blenkernel
778                 bf_nodes
779                 bf_gpu
780                 bf_blenloader
781                 bf_blenlib
782                 bf_intern_ghost
783                 bf_intern_string
784                 bf_blenpluginapi
785                 bf_imbuf
786                 bf_avi
787                 bf_imbuf_cineon
788                 bf_imbuf_openexr
789                 bf_imbuf_dds
790                 bf_readblenfile
791                 bf_collada
792                 bf_intern_bsp
793                 bf_intern_bop
794                 bf_gen_system
795                 bf_intern_decimate
796                 bf_intern_elbeem
797                 bf_intern_ik
798                 bf_intern_memutil
799                 bf_intern_guardedalloc
800                 bf_intern_ctr
801                 ge_blen_routines
802                 ge_converter
803                 ge_phys_dummy
804                 ge_phys_bullet
805                 bf_intern_smoke
806                 extern_minilzo
807                 extern_lzma
808                 ge_logic_ketsji
809                 ge_phys_common
810                 ge_logic
811                 ge_rasterizer
812                 ge_oglrasterizer
813                 ge_logic_expressions
814                 ge_scenegraph
815                 ge_logic_network
816                 bf_gen_system
817                 bf_python # duplicate for BPY_driver_exec
818                 ge_logic_ngnetwork
819                 extern_bullet
820                 ge_logic_loopbacknetwork
821                 bf_intern_moto
822                 extern_openjpeg
823                 extern_redcode
824                 ge_videotex
825                 bf_rna
826                 bf_dna
827                 bf_blenfont
828                 bf_intern_audaspace
829                 bf_intern_mikktspace
830         )
831
832     if(WITH_MOD_CLOTH_ELTOPO)
833                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
834     endif()
835
836     if(WITH_BUILTIN_GLEW)
837                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
838     endif()
839
840         if(WITH_BINRELOC)
841                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
842         endif()
843
844         if(WITH_CXX_GUARDEDALLOC)
845                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
846         endif()
847
848         if(WITH_IK_ITASC)
849                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
850         endif()
851
852         if(WITH_CODEC_QUICKTIME)
853                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
854         endif()
855
856         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
857                 set(REMLIB ${SORTLIB})
858                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
859                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
860                                 set(REMLIB "")
861                         endif()
862                 endforeach()
863                 if(REMLIB)
864                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
865                         list(APPEND REM_MSG ${REMLIB})
866                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
867                 endif()
868         endforeach()
869         if(REM_MSG)
870                 list(SORT REM_MSG)
871                 message(STATUS "Blender Skipping: (${REM_MSG})")
872         endif()
873         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
874 #else()
875 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
876 #endif()
877
878 setup_liblinks(blender)