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