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