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