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