Merged changes in the trunk up to revision 41225.
[blender-staging.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 setup_libdirs()
29
30 blender_include_dirs(
31         ../../intern/guardedalloc
32         ../blender/blenlib
33         ../blender/blenkernel
34         ../blender/blenloader
35         ../blender/editors/include
36         ../blender/makesrna
37         ../blender/imbuf
38         ../blender/render/extern/include
39         ../blender/makesdna
40         ../blender/gpu
41         ../blender/freestyle
42         ../blender/windowmanager
43 )
44
45 if(WITH_CODEC_QUICKTIME)
46         add_definitions(-DWITH_QUICKTIME)
47 endif()
48
49 if(WITH_IMAGE_OPENEXR)
50         add_definitions(-DWITH_OPENEXR)
51 endif()
52
53 if(WITH_IMAGE_OPENJPEG)
54         add_definitions(-DWITH_OPENJPEG)
55 endif()
56
57 if(WITH_IMAGE_TIFF)
58         add_definitions(-DWITH_TIFF)
59 endif()
60
61 if(WITH_IMAGE_DDS)
62         add_definitions(-DWITH_DDS)
63 endif()
64
65 if(WITH_IMAGE_CINEON)
66         add_definitions(-DWITH_CINEON)
67 endif()
68
69 if(WITH_IMAGE_HDR)
70         add_definitions(-DWITH_HDR)
71 endif()
72
73 if(WITH_PYTHON)
74         blender_include_dirs(../blender/python)
75         add_definitions(-DWITH_PYTHON)
76
77         if(WITH_PYTHON_SECURITY)
78                 add_definitions(-DWITH_PYTHON_SECURITY)
79         endif()
80 endif()
81
82 if(WITH_HEADLESS)
83         add_definitions(-DWITH_HEADLESS)
84 endif()
85
86 if(WITH_GAMEENGINE)
87         blender_include_dirs(../gameengine/BlenderRoutines)
88
89         add_definitions(-DWITH_GAMEENGINE)
90 endif()
91
92 if(WITH_SDL)
93         add_definitions(-DWITH_SDL)
94 endif()
95
96 if(WITH_BINRELOC)
97         add_definitions(-DWITH_BINRELOC)
98         blender_include_dirs(${BINRELOC_INCLUDE_DIRS})
99 endif()
100
101 # Setup the exe sources and buildinfo
102 set(SRC
103         creator.c
104 )
105
106 # MSVC 2010 gives linking errors with the manifest
107 if(WIN32 AND NOT UNIX)
108         string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
109         string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
110         string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
111         if(MINGW)
112                 add_definitions(
113                         -DWINDRES
114                         -DBLEN_VER_RC_STR_M=${BLENDER_VERSION}
115                         -DBLEN_VER_RC_1=${bver1}
116                         -DBLEN_VER_RC_2=${bver2}
117                         -DBLEN_VER_RC_3=${bver3}
118                         -DBLEN_VER_RC_4=0
119                 )
120         else()
121                 add_definitions(
122                         -DBLEN_VER_RC_STR=${BLENDER_VERSION}
123                         -DBLEN_VER_RC_1=${bver1}
124                         -DBLEN_VER_RC_2=${bver2}
125                         -DBLEN_VER_RC_3=${bver3}
126                         -DBLEN_VER_RC_4=0
127                 )
128         endif()
129
130
131         list(APPEND SRC
132                 ../icons/winblender.rc
133         )
134 endif()
135
136 if(WITH_BUILDINFO)
137         add_definitions(-DWITH_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
234 # -----------------------------------------------------------------------------
235 # Install Targets
236
237 set(BLENDER_TEXT_FILES
238         ${CMAKE_SOURCE_DIR}/release/text/GPL-license.txt
239         ${CMAKE_SOURCE_DIR}/release/text/Python-license.txt
240         ${CMAKE_SOURCE_DIR}/release/text/copyright.txt
241         ${CMAKE_SOURCE_DIR}/release/text/readme.html
242 )
243
244 if(UNIX AND NOT APPLE)
245
246         if(WITH_INSTALL_PORTABLE)
247                 set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
248         else()
249                 if(WITH_PYTHON_MODULE)
250                         set(TARGETDIR_VER ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/${BLENDER_VERSION})
251                 else()
252                         set(TARGETDIR_VER ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION})
253                 endif()
254         endif()
255
256         # important to make a clean  install each time
257         # else old scripts get loaded.
258         install(
259                 CODE
260                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
261         )
262
263         # message after building.
264         add_custom_command(
265                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
266                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${TARGETDIR_VER}'
267         )
268
269         # there are a few differences between portable and system install
270         if(WITH_INSTALL_PORTABLE)
271                 install(
272                         FILES
273                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
274                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
275                                 ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
276                         DESTINATION ${TARGETDIR}
277                 )
278
279                 install(
280                         PROGRAMS
281                         ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
282                         DESTINATION ${TARGETDIR}
283                 )
284
285                 install(
286                         FILES ${BLENDER_TEXT_FILES}
287                         DESTINATION ${TARGETDIR}
288                 )
289
290         else()
291                 # main blender binary
292                 if(WITH_PYTHON_MODULE)
293                         install(
294                                 TARGETS blender
295                                 LIBRARY
296                                 DESTINATION ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages
297                         )
298                 else()
299                         install(
300                                 PROGRAMS ${TARGETDIR}/blender
301                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
302                         )
303                 endif()
304
305
306                 if(WITH_GAMEENGINE AND WITH_PLAYER)
307                         install(
308                                 PROGRAMS ${TARGETDIR}/blenderplayer
309                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
310                         )
311                 endif()
312
313                 # misc files
314                 install(
315                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
316                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
317                 )
318                 install(
319                         DIRECTORY
320                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/16x16
321                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/22x22
322                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/24x24
323                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/32x32
324                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48
325                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256
326                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor
327                         PATTERN ".svn" EXCLUDE
328                         PATTERN "*.svg" EXCLUDE
329                 )
330                 install(
331                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
332                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps
333                 )
334                 install(
335                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
336                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
337                 )
338                 install(
339                         FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
340                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
341                 )
342                 install(
343                         FILES ${BLENDER_TEXT_FILES}
344                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
345                 )
346         endif()
347
348         if(WITH_INTERNATIONAL)
349                 install(
350                         DIRECTORY
351                                 ${CMAKE_SOURCE_DIR}/release/datafiles/locale
352                                 ${CMAKE_SOURCE_DIR}/release/datafiles/fonts
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               # * any cache *
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 "idlelib" EXCLUDE                   # ./idlelib
392                                 PATTERN "test" EXCLUDE                      # ./test
393                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
394                                 PATTERN "turtle.py" EXCLUDE                                     # ./turtle.py
395                         )
396
397                         # # doesnt work, todo
398                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
399                 endif()
400         endif()
401 elseif(WIN32)
402
403         set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
404
405         install(  # same as linux!, deduplicate
406                 CODE
407                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
408         )
409
410         install(  # same as linux!, deduplicate
411                 FILES ${BLENDER_TEXT_FILES}
412                 DESTINATION ${TARGETDIR}
413         )
414
415         if(WITH_INTERNATIONAL) # same as linux!, deduplicate
416                 install(
417                         DIRECTORY
418                                 ${CMAKE_SOURCE_DIR}/release/datafiles/locale
419                                 ${CMAKE_SOURCE_DIR}/release/datafiles/fonts
420                         DESTINATION ${TARGETDIR_VER}/datafiles
421                         PATTERN ".svn" EXCLUDE
422                 )
423
424                 install(
425                         FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
426                         DESTINATION ${TARGETDIR}
427                 )
428
429                 if(NOT CMAKE_CL_64)
430                         install(
431                                 FILES ${LIBDIR}/iconv/lib/iconv.dll
432                                 DESTINATION ${TARGETDIR}
433                         )
434                 endif()
435         endif()
436
437         # plugins in blender 2.5 don't work at the moment.
438         #
439         # install(
440         #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
441         #       DESTINATION ${TARGETDIR_VER}
442         #       PATTERN ".svn" EXCLUDE
443         # )
444
445         if(WITH_PYTHON)
446                 # install(CODE "message(\"copying blender scripts...\")")
447                 install(  # same as linux!, deduplicate
448                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
449                         DESTINATION ${TARGETDIR_VER}
450                         PATTERN ".svn" EXCLUDE
451                         PATTERN "__pycache__" EXCLUDE
452                 )
453
454                 install(
455                         FILES ${LIBDIR}/python/lib/python32.dll
456                         DESTINATION ${TARGETDIR}
457                         CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
458                 )
459
460                 install(
461                         FILES ${LIBDIR}/python/lib/python32_d.dll
462                         DESTINATION ${TARGETDIR}
463                         CONFIGURATIONS Debug
464                 )
465
466                 if(WITH_PYTHON_INSTALL)
467                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
468
469                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
470                         install(
471                                 CODE
472                                 "
473                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
474                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\")
475                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\")
476                                 message(\"done creating dir\")
477                                 "
478                         )
479
480                         install(
481                                 CODE
482                                 "
483                                 if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
484                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
485                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32_d.tar.gz\")
486                                 else()
487                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
488                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
489                                 endif()
490                                 "
491                         )
492
493                         # doesnt work, todo
494                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
495                 endif()
496         endif()
497
498         if(CMAKE_CL_64)
499                 # gettext and png are statically linked on win64
500                 install(
501                         FILES ${LIBDIR}/zlib/lib/zlib.dll
502                         DESTINATION ${TARGETDIR}
503                 )
504         else()
505                 install(
506                         FILES
507                                 ${LIBDIR}/png/lib/libpng.dll
508                                 ${LIBDIR}/zlib/lib/zlib.dll
509                         DESTINATION ${TARGETDIR}
510                 )
511         endif()
512
513         if(MSVC)
514                 install(
515                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
516                         DESTINATION ${TARGETDIR}
517                 )
518         else()
519                 install(
520                         FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
521                         DESTINATION ${TARGETDIR}
522                 )
523         endif()
524
525         if(WITH_CODEC_FFMPEG)
526                 install(
527                         FILES
528                                 ${LIBDIR}/ffmpeg/lib/avcodec-53.dll
529                                 ${LIBDIR}/ffmpeg/lib/avformat-53.dll
530                                 ${LIBDIR}/ffmpeg/lib/avdevice-53.dll
531                                 ${LIBDIR}/ffmpeg/lib/avutil-51.dll
532                                 ${LIBDIR}/ffmpeg/lib/swscale-2.dll
533                         DESTINATION ${TARGETDIR}
534                 )
535
536         endif()
537
538         if(WITH_CODEC_SNDFILE)
539                 install(
540                         FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
541                         DESTINATION ${TARGETDIR}
542                 )
543         endif()
544
545         if(WITH_OPENAL)
546                 install(
547                         FILES
548                                 ${LIBDIR}/openal/lib/OpenAL32.dll
549                                 ${LIBDIR}/openal/lib/wrap_oal.dll
550                         DESTINATION ${TARGETDIR}
551                 )
552         endif()
553
554         if(WITH_SDL)
555                 if(NOT CMAKE_CL_64)
556                         install(
557                                 FILES ${LIBDIR}/sdl/lib/SDL.dll
558                                 DESTINATION ${TARGETDIR}
559                         )
560                 endif()
561         endif()
562
563         if(NOT CMAKE_CL_64)
564                 install(
565                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
566                         DESTINATION ${TARGETDIR}
567                 )
568         endif()
569                 
570         install( # x86 builds can run on x64 Windows, so this is required at all times
571                 FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
572                 DESTINATION ${TARGETDIR}
573         )       
574
575 elseif(APPLE)
576         set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
577         set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
578         set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
579
580         # setup Info.plist
581         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
582
583         set_target_properties(blender PROPERTIES
584                 MACOSX_BUNDLE_INFO_PLIST ${SOURCEINFO}
585                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
586                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
587
588         # important to make a clean  install each time else old scripts get loaded.
589         install(
590                 CODE
591                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
592         )
593
594         # message after building.
595         add_custom_command(
596                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
597                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${TARGETDIR_VER}'
598         )
599
600         # handy install macro to exclude files, we use \$ escape for the "to"
601         # argument when calling so ${BUILD_TYPE} does not get expanded
602         macro(install_dir from to)
603                 install(
604                         DIRECTORY ${from}
605                         DESTINATION ${to}
606                         PATTERN ".svn" EXCLUDE
607                         PATTERN "*.pyc" EXCLUDE
608                         PATTERN "*.pyo" EXCLUDE
609                         PATTERN "*.orig" EXCLUDE
610                         PATTERN "*.rej" EXCLUDE
611                         PATTERN "__pycache__" EXCLUDE
612                         PATTERN "__MACOSX" EXCLUDE
613                         PATTERN ".DS_Store" EXCLUDE
614                 )
615         endmacro()
616
617         # install release and app files
618         install(
619                 FILES ${BLENDER_TEXT_FILES}
620                 DESTINATION ${TARGETDIR}
621         )
622
623         install(
624                 FILES ${SOURCEDIR}/Contents/PkgInfo
625                 DESTINATION ${TARGETDIR}/blender.app/Contents
626         )
627
628         install_dir(
629                 ${SOURCEDIR}/Contents/Resources
630                 \${TARGETDIR}/blender.app/Contents/
631         )
632
633         # localization
634         if(WITH_INTERNATIONAL)
635                 install(
636                         DIRECTORY
637                                 ${CMAKE_SOURCE_DIR}/release/datafiles/locale
638                                 ${CMAKE_SOURCE_DIR}/release/datafiles/fonts
639                         DESTINATION ${TARGETDIR_VER}/datafiles
640                         PATTERN ".svn" EXCLUDE
641                 )
642         endif()
643
644         # python
645         if(WITH_PYTHON)
646                 # the python zip is first extract as part of the build process,
647                 # and then later installed as part of make install. this is much
648                 # quicker, and means we can easily exclude files on copy
649                 add_custom_target(
650                         extractpyzip
651                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
652
653                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
654
655                 add_custom_command(
656                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
657                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
658                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
659                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
660                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
661
662                 add_dependencies(blender extractpyzip)
663
664                 # copy extracted python files
665                 install_dir(
666                         ${CMAKE_CURRENT_BINARY_DIR}/python
667                         \${TARGETDIR_VER}
668                 )
669
670                 # copy scripts
671                 install_dir(
672                         ${CMAKE_SOURCE_DIR}/release/scripts
673                         \${TARGETDIR_VER}
674                 )
675         endif()
676
677         # install blenderplayer bundle - copy of blender.app above. re-using macros et al
678         # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
679         if(WITH_GAMEENGINE AND WITH_PLAYER)
680                 set(PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blenderplayer.app)
681                 set(PLAYER_SOURCEINFO ${PLAYER_SOURCEDIR}/Contents/Info.plist)
682                 set(PLAYER_TARGETDIR_VER ${TARGETDIR}/blenderplayer.app/Contents/MacOS/${BLENDER_VERSION})
683
684
685                 # important to make a clean  install each time else old scripts get loaded.
686                 install(
687                         CODE
688                         "file(REMOVE_RECURSE ${PLAYER_TARGETDIR_VER})"
689                 )
690
691                 install(
692                         FILES ${PLAYER_SOURCEDIR}/Contents/PkgInfo
693                         DESTINATION ${TARGETDIR}/blenderplayer.app/Contents
694                 )
695
696                 install_dir(
697                         ${PLAYER_SOURCEDIR}/Contents/Resources
698                         \${TARGETDIR}/blenderplayer.app/Contents/
699                 )
700
701                 # python
702                 if(WITH_PYTHON)
703                         add_custom_command(
704                                 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
705                                 COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
706                                 COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
707                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
708                                 DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
709
710                         # copy extracted python files
711                         install_dir(
712                                 ${CMAKE_CURRENT_BINARY_DIR}/python
713                                 \${PLAYER_TARGETDIR_VER}
714                         )
715                 endif()
716
717         endif()
718 endif()
719
720 unset(BLENDER_TEXT_FILES)
721
722
723 # -----------------------------------------------------------------------------
724 # Setup link libs
725
726 add_dependencies(blender makesdna)
727
728 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
729
730 set(BLENDER_LINK_LIBS
731         ${BLENDER_LINK_LIBS}
732         bf_windowmanager
733         bf_render
734 )
735
736 if(WITH_MOD_FLUID)
737         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
738 endif()
739
740 #if(UNIX)
741         # Sort libraries
742         set(BLENDER_SORTED_LIBS
743                 bf_windowmanager
744
745                 bf_editor_space_api
746                 bf_editor_space_action
747                 bf_editor_space_buttons
748                 bf_editor_space_console
749                 bf_editor_space_file
750                 bf_editor_space_graph
751                 bf_editor_space_image
752                 bf_editor_space_info
753                 bf_editor_space_logic
754                 bf_editor_space_nla
755                 bf_editor_space_node
756                 bf_editor_space_outliner
757                 bf_editor_space_script
758                 bf_editor_space_sequencer
759                 bf_editor_space_sound
760                 bf_editor_space_time
761                 bf_editor_space_userpref
762                 bf_editor_space_view3d
763
764                 bf_editor_text
765                 bf_editor_transform
766                 bf_editor_util
767                 bf_editor_uvedit
768                 bf_editor_curve
769                 bf_editor_armature
770                 bf_editor_gpencil
771                 bf_editor_interface
772                 bf_editor_mesh
773                 bf_editor_metaball
774                 bf_editor_object
775                 bf_editor_physics
776                 bf_editor_render
777                 bf_editor_screen
778                 bf_editor_sculpt_paint
779                 bf_editor_sound
780                 bf_editor_animation
781                 bf_editor_datafiles
782
783                 bf_render
784                 bf_intern_opennl
785                 bf_python
786                 bf_python_ext
787                 bf_python_mathutils
788                 bf_freestyle
789                 bf_ikplugin
790                 bf_modifiers
791                 bf_blenkernel
792                 bf_nodes
793                 bf_gpu
794                 bf_blenloader
795                 bf_blenlib
796                 bf_intern_ghost
797                 bf_intern_string
798                 bf_blenpluginapi
799                 bf_imbuf
800                 bf_avi
801                 bf_imbuf_cineon
802                 bf_imbuf_openexr
803                 bf_imbuf_dds
804                 bf_collada
805                 bf_intern_bsp
806                 bf_intern_bop
807                 bf_intern_decimate
808                 bf_intern_elbeem
809                 bf_intern_ik
810                 bf_intern_memutil
811                 bf_intern_guardedalloc
812                 bf_intern_ctr
813                 ge_blen_routines
814                 ge_converter
815                 ge_phys_dummy
816                 ge_phys_bullet
817                 bf_intern_smoke
818                 extern_minilzo
819                 extern_lzma
820                 ge_logic_ketsji
821                 extern_recastnavigation
822                 ge_phys_common
823                 ge_logic
824                 ge_rasterizer
825                 ge_oglrasterizer
826                 ge_logic_expressions
827                 ge_scenegraph
828                 ge_logic_network
829                 ge_logic_ngnetwork
830                 extern_bullet
831                 ge_logic_loopbacknetwork
832                 bf_intern_moto
833                 extern_openjpeg
834                 extern_redcode
835                 ge_videotex
836                 bf_rna
837                 bf_dna
838                 bf_blenfont
839                 bf_intern_audaspace
840                 bf_intern_mikktspace
841         )
842
843         if(WITH_MOD_CLOTH_ELTOPO)
844                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
845         endif()
846
847         if(WITH_BUILTIN_GLEW)
848                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
849         endif()
850
851         if(WITH_BINRELOC)
852                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
853         endif()
854
855         if(WITH_CXX_GUARDEDALLOC)
856                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
857         endif()
858
859         if(WITH_IK_ITASC)
860                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
861         endif()
862
863         if(WITH_CODEC_QUICKTIME)
864                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
865         endif()
866
867         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
868                 set(REMLIB ${SORTLIB})
869                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
870                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
871                                 set(REMLIB "")
872                         endif()
873                 endforeach()
874                 if(REMLIB)
875                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
876                         list(APPEND REM_MSG ${REMLIB})
877                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
878                 endif()
879         endforeach()
880         if(REM_MSG)
881                 list(SORT REM_MSG)
882                 message(STATUS "Blender Skipping: (${REM_MSG})")
883         endif()
884         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
885
886         unset(SEARCHLIB)
887         unset(SORTLIB)
888         unset(REMLIB)
889         unset(REM_MSG)
890
891 #else()
892 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
893 #endif()
894
895 setup_liblinks(blender)