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