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