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