fix for installing blender as a python module with cmake.
[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                         install(
282                                 TARGETS blender
283                                 LIBRARY
284                                 DESTINATION ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages
285                         )
286                 else()
287                         install(
288                                 PROGRAMS ${TARGETDIR}/blender
289                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
290                         )
291                 endif()
292
293
294                 if(WITH_GAMEENGINE AND WITH_PLAYER)
295                         install(
296                                 PROGRAMS ${TARGETDIR}/blenderplayer
297                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
298                         )
299                 endif()
300
301                 # misc files
302                 install(
303                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
304                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
305                 )
306                 install(
307                         DIRECTORY
308                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/16x16
309                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/22x22
310                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/24x24
311                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/32x32
312                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48
313                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256
314                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor
315                         PATTERN ".svn" EXCLUDE
316                         PATTERN "*.svg" EXCLUDE
317                 )
318                 install(
319                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
320                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps
321                 )
322                 install(
323                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
324                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
325                 )
326                 install(
327                         FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
328                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
329                 )
330                 install(
331                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/text
332                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
333                         PATTERN ".svn" EXCLUDE
334                 )
335         endif()
336
337         install(
338                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
339                 DESTINATION ${TARGETDIR_VER}/config
340         )
341
342         if(WITH_INTERNATIONAL)
343                 install(
344                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
345                         DESTINATION ${TARGETDIR_VER}/config
346                 )
347
348                 install(
349                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
350                         DESTINATION ${TARGETDIR_VER}/datafiles
351                         PATTERN ".svn" EXCLUDE
352                 )
353         endif()
354
355                 # plugins in blender 2.5 don't work at the moment.
356                 #
357                 # install(
358                 #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
359                 #       DESTINATION ${TARGETDIR_VER}
360                 #       PATTERN ".svn" EXCLUDE
361                 # )
362
363         if(WITH_PYTHON)
364                 # install(CODE "message(\"copying blender scripts...\")")
365                 install(
366                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
367                         DESTINATION ${TARGETDIR_VER}
368                         PATTERN ".svn" EXCLUDE
369                         PATTERN "__pycache__" EXCLUDE
370                 )
371
372                 if(WITH_PYTHON_INSTALL)
373                         # Copy the systems python into the install directory
374                         # Scons copy in tools/Blender.py
375                         # install(CODE "message(\"copying a subset of the systems python...\")")
376                         install(
377                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
378                                 DESTINATION ${TARGETDIR_VER}/python/lib
379                                 PATTERN ".svn" EXCLUDE
380                                 PATTERN "__pycache__" EXCLUDE               # * any cache *
381                                 PATTERN "distutils" EXCLUDE                 # ./distutils
382                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
383                                 PATTERN "config" EXCLUDE                    # ./config
384                                 PATTERN "config-*" EXCLUDE                  # ./config-*
385                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
386                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
387                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
388                                 PATTERN "idlelib" EXCLUDE                   # ./idlelib
389                                 PATTERN "test" EXCLUDE                      # ./test
390                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
391                                 PATTERN "turtle.py" EXCLUDE                                     # ./turtle.py
392                         )
393
394                         # # doesnt work, todo
395                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
396                 endif()
397         endif()
398 elseif(WIN32)
399
400         set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
401
402         install(  # same as linux!, deduplicate
403                 CODE
404                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
405         )
406
407         install(  # same as linux!, deduplicate
408                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/text
409                 DESTINATION ${TARGETDIR}
410                 PATTERN ".svn" EXCLUDE
411         )
412
413         install(  # same as linux!, deduplicate
414                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
415                 DESTINATION ${TARGETDIR_VER}/config
416         )
417
418         if(WITH_INTERNATIONAL) # same as linux!, deduplicate
419                 install(
420                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
421                         DESTINATION ${TARGETDIR_VER}/config
422                 )
423                 install(
424                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
425                         DESTINATION ${TARGETDIR_VER}/datafiles
426                         PATTERN ".svn" EXCLUDE
427                 )
428
429                 if(NOT CMAKE_CL_64)
430                         install(
431                                 FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
432                                 DESTINATION ${TARGETDIR}
433                         )
434
435                         install(
436                                 FILES ${LIBDIR}/iconv/lib/iconv.dll
437                                 DESTINATION ${TARGETDIR}
438                         )
439                 endif()
440         endif()
441
442         install( # same as linux!, deduplicate
443                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
444                 DESTINATION ${TARGETDIR_VER}/datafiles/locale
445                 PATTERN ".svn" EXCLUDE
446         )
447
448         # plugins in blender 2.5 don't work at the moment.
449         #
450         # install(
451         #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
452         #       DESTINATION ${TARGETDIR_VER}
453         #       PATTERN ".svn" EXCLUDE
454         # )
455
456         if(WITH_PYTHON)
457                 # install(CODE "message(\"copying blender scripts...\")")
458                 install(  # same as linux!, deduplicate
459                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
460                         DESTINATION ${TARGETDIR_VER}
461                         PATTERN ".svn" EXCLUDE
462                         PATTERN "__pycache__" EXCLUDE
463                 )
464
465                 # TODO, multiple targets?
466                 install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR} CONFIGURATIONS Release)
467                 install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR} CONFIGURATIONS RelWithDebInfo)
468                 install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR} CONFIGURATIONS MinSizeRel)
469
470                 install(
471                         FILES ${LIBDIR}/python/lib/python32_d.dll
472                         DESTINATION ${TARGETDIR}
473                         CONFIGURATIONS Debug
474                 )
475
476                 if(WITH_PYTHON_INSTALL)
477                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
478
479                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
480                         install(
481                                 CODE
482                                 "
483                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
484                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\")
485                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\")
486                                 message(\"done creating dir\")
487                                 "
488                         )
489
490                         install(
491                                 CODE
492                                 "
493                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
494                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
495                                 "
496                                 CONFIGURATIONS Release
497                         )
498                         install(
499                                 CODE
500                                 "
501                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
502                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
503                                 "
504                                 CONFIGURATIONS RelWithDebInfo
505                         )
506                         install(
507                                 CODE
508                                 "
509                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
510                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
511                                 "
512                                 CONFIGURATIONS MinSizeRel
513                         )
514                         install(
515                                 CODE
516                                 "
517                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
518                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32_d.tar.gz\")
519                                 "
520                                 CONFIGURATIONS Debug
521                         )
522
523                         # doesnt work, todo
524                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
525                 endif()
526         endif()
527
528         if(CMAKE_CL_64)
529                 # gettext and png are statically linked on win64
530                 install(
531                         FILES ${LIBDIR}/zlib/lib/zlib.dll
532                         DESTINATION ${TARGETDIR}
533                 )
534         else()
535                 install(
536                         FILES
537                         ${LIBDIR}/png/lib/libpng.dll
538                         ${LIBDIR}/zlib/lib/zlib.dll
539                         DESTINATION ${TARGETDIR}
540                 )
541         endif()
542
543         if(MSVC)
544                 install(
545                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
546                         DESTINATION ${TARGETDIR}
547                 )
548         else()
549                 install(
550                         FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
551                         DESTINATION ${TARGETDIR}
552                 )
553         endif()
554
555         if(WITH_CODEC_FFMPEG)
556                 install(
557                         FILES
558                         ${LIBDIR}/ffmpeg/lib/avcodec-52.dll
559                         ${LIBDIR}/ffmpeg/lib/avformat-52.dll
560                         ${LIBDIR}/ffmpeg/lib/avdevice-52.dll
561                         ${LIBDIR}/ffmpeg/lib/avutil-50.dll
562                         ${LIBDIR}/ffmpeg/lib/swscale-0.dll
563                         DESTINATION ${TARGETDIR}
564                 )
565
566         endif()
567
568         if(WITH_CODEC_SNDFILE)
569                 install(
570                         FILES
571                         ${LIBDIR}/sndfile/lib/libsndfile-1.dll
572                         DESTINATION ${TARGETDIR}
573                 )
574         endif()
575
576         if(WITH_OPENAL)
577                 install(
578                         FILES
579                         ${LIBDIR}/openal/lib/OpenAL32.dll
580                         ${LIBDIR}/openal/lib/wrap_oal.dll
581                         DESTINATION ${TARGETDIR}
582                 )
583         endif()
584
585         if(WITH_SDL)
586                 if(NOT CMAKE_CL_64)
587                         install(
588                                 FILES
589                                 ${LIBDIR}/sdl/lib/SDL.dll
590                                 DESTINATION ${TARGETDIR}
591                         )
592                 endif()
593         endif()
594
595         if(NOT CMAKE_CL_64)
596                 install(
597                         FILES
598                         ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
599                         DESTINATION ${TARGETDIR}
600                 )
601         else()
602                 install(
603                         FILES
604                         ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
605                         DESTINATION ${TARGETDIR}
606                 )
607         endif()
608
609 elseif(APPLE)
610         set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
611         set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
612         set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
613
614         # setup Info.plist
615         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
616
617         set_target_properties(blender PROPERTIES
618                 MACOSX_BUNDLE_INFO_PLIST ${SOURCEINFO}
619                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
620                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
621
622         # important to make a clean  install each time else old scripts get loaded.
623         install(
624                 CODE
625                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
626         )
627
628         # message after building.
629         add_custom_command(
630                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
631                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${TARGETDIR_VER}'
632         )
633
634         # handy install macro to exclude files, we use \$ escape for the "to"
635         # argument when calling so ${BUILD_TYPE} does not get expanded
636         macro(install_dir from to)
637                 install(
638                         DIRECTORY ${from}
639                         DESTINATION ${to}
640                         PATTERN ".svn" EXCLUDE
641                         PATTERN "*.pyc" EXCLUDE
642                         PATTERN "*.pyo" EXCLUDE
643                         PATTERN "*.orig" EXCLUDE
644                         PATTERN "*.rej" EXCLUDE
645                         PATTERN "__pycache__" EXCLUDE
646                         PATTERN "__MACOSX" EXCLUDE
647                         PATTERN ".DS_Store" EXCLUDE
648                 )
649         endmacro()
650
651         # install release and app files
652         install_dir(
653                 ${CMAKE_SOURCE_DIR}/release/text/
654                 \${TARGETDIR}
655         )
656
657         install(
658                 FILES ${SOURCEDIR}/Contents/PkgInfo
659                 DESTINATION ${TARGETDIR}/blender.app/Contents
660         )
661
662         install_dir(
663                 ${SOURCEDIR}/Contents/Resources
664                 \${TARGETDIR}/blender.app/Contents/
665         )
666
667         install(
668                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
669                 DESTINATION ${TARGETDIR_VER}/datafiles
670         )
671
672         # localization
673         if(WITH_INTERNATIONAL)
674                 install(
675                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
676                         DESTINATION ${TARGETDIR_VER}/datafiles
677                 )
678
679                 install_dir(
680                         ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/
681                         \${TARGETDIR_VER}/datafiles/locale
682                 )
683         endif()
684
685         # python
686         if(WITH_PYTHON)
687                 # the python zip is first extract as part of the build process,
688                 # and then later installed as part of make install. this is much
689                 # quicker, and means we can easily exclude files on copy
690                 add_custom_target(
691                         extractpyzip
692                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
693
694                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
695                         
696                 add_custom_command(
697                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
698                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
699                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
700                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
701                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
702                 
703                 add_dependencies(blender extractpyzip)
704
705                 # copy extracted python files
706                 install_dir(
707                         ${CMAKE_CURRENT_BINARY_DIR}/python
708                         \${TARGETDIR_VER}
709                 )
710
711                 # copy scripts
712                 install_dir(
713                         ${CMAKE_SOURCE_DIR}/release/scripts
714                         \${TARGETDIR_VER}
715                 )
716         endif()
717 endif()
718
719 add_dependencies(blender makesdna)
720
721 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
722
723 set(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
724
725 if(WITH_MOD_FLUID)
726         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
727 endif()
728
729
730 #if(UNIX)
731         # Sort libraries
732         set(BLENDER_SORTED_LIBS
733                 bf_windowmanager
734
735                 bf_editor_space_api
736                 bf_editor_space_action
737                 bf_editor_space_buttons
738                 bf_editor_space_console
739                 bf_editor_space_file
740                 bf_editor_space_graph
741                 bf_editor_space_image
742                 bf_editor_space_info
743                 bf_editor_space_logic
744                 bf_editor_space_nla
745                 bf_editor_space_node
746                 bf_editor_space_outliner
747                 bf_editor_space_script
748                 bf_editor_space_sequencer
749                 bf_editor_space_sound
750                 bf_editor_space_time
751                 bf_editor_space_userpref
752                 bf_editor_space_view3d
753
754                 bf_editor_text
755                 bf_editor_transform
756                 bf_editor_util
757                 bf_editor_uvedit
758                 bf_editor_curve
759                 bf_editor_armature
760                 bf_editor_gpencil
761                 bf_editor_interface
762                 bf_editor_mesh
763                 bf_editor_metaball
764                 bf_editor_object
765                 bf_editor_physics
766                 bf_editor_render
767                 bf_editor_screen
768                 bf_editor_sculpt_paint
769                 bf_editor_sound
770                 bf_editor_animation
771                 bf_editor_datafiles
772
773                 bf_render
774                 bf_intern_opennl
775                 bf_python
776                 bf_python_ext
777                 bf_ikplugin
778                 bf_modifiers
779                 bf_blenkernel
780                 bf_nodes
781                 bf_gpu
782                 bf_blenloader
783                 bf_blenlib
784                 bf_intern_ghost
785                 bf_intern_string
786                 bf_blenpluginapi
787                 bf_imbuf
788                 bf_avi
789                 bf_imbuf_cineon
790                 bf_imbuf_openexr
791                 bf_imbuf_dds
792                 bf_collada
793                 bf_intern_bsp
794                 bf_intern_bop
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_python # duplicate for BPY_driver_exec
817                 ge_logic_ngnetwork
818                 extern_bullet
819                 ge_logic_loopbacknetwork
820                 bf_intern_moto
821                 extern_openjpeg
822                 extern_redcode
823                 ge_videotex
824                 bf_rna
825                 bf_dna
826                 bf_blenfont
827                 bf_intern_audaspace
828                 bf_intern_mikktspace
829         )
830
831         if(WITH_MOD_CLOTH_ELTOPO)
832                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
833         endif()
834
835         if(WITH_BUILTIN_GLEW)
836                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
837         endif()
838
839         if(WITH_BINRELOC)
840                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
841         endif()
842
843         if(WITH_CXX_GUARDEDALLOC)
844                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
845         endif()
846
847         if(WITH_IK_ITASC)
848                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
849         endif()
850
851         if(WITH_CODEC_QUICKTIME)
852                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
853         endif()
854
855         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
856                 set(REMLIB ${SORTLIB})
857                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
858                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
859                                 set(REMLIB "")
860                         endif()
861                 endforeach()
862                 if(REMLIB)
863                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
864                         list(APPEND REM_MSG ${REMLIB})
865                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
866                 endif()
867         endforeach()
868         if(REM_MSG)
869                 list(SORT REM_MSG)
870                 message(STATUS "Blender Skipping: (${REM_MSG})")
871         endif()
872         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
873 #else()
874 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
875 #endif()
876
877 setup_liblinks(blender)