Drag-n-drop support on Linux
[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                         # on some platforms (like openSUSE) Python is linked
402                         # to be used from lib64 folder.
403                         # determine this from Python's libraries path
404                         if(${PYTHON_LIBPATH} MATCHES "lib64$")
405                                 set(_target_LIB "lib64")
406                         else()
407                                 set(_target_LIB "lib")
408                         endif()
409
410                         # Copy the systems python into the install directory
411                         # Scons copy in tools/Blender.py
412                         # install(CODE "message(\"copying a subset of the systems python...\")")
413                         install(
414                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
415                                 DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}
416                                 PATTERN ".svn" EXCLUDE
417                                 PATTERN "__pycache__" EXCLUDE               # * any cache *
418                                 PATTERN "distutils" EXCLUDE                 # ./distutils
419                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
420                                 PATTERN "config" EXCLUDE                    # ./config
421                                 PATTERN "config-*" EXCLUDE                  # ./config-*
422                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
423                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
424                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
425                                 PATTERN "idlelib" EXCLUDE                   # ./idlelib
426                                 PATTERN "test" EXCLUDE                      # ./test
427                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
428                                 PATTERN "turtle.py" EXCLUDE                                     # ./turtle.py
429                         )
430
431                         # # doesnt work, todo
432                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
433                         unset(_target_LIB)
434                 endif()
435         endif()
436 elseif(WIN32)
437
438         install(
439                 FILES ${BLENDER_TEXT_FILES}
440                 DESTINATION ${TARGETDIR}
441         )
442
443         if(WITH_INTERNATIONAL)
444                 install(
445                         FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
446                         DESTINATION ${TARGETDIR}
447                 )
448
449                 if(NOT CMAKE_CL_64)
450                         install(
451                                 FILES ${LIBDIR}/iconv/lib/iconv.dll
452                                 DESTINATION ${TARGETDIR}
453                         )
454                 endif()
455         endif()
456
457         # plugins in blender 2.5 don't work at the moment.
458         #
459         # install(
460         #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
461         #       DESTINATION ${TARGETDIR_VER}
462         #       PATTERN ".svn" EXCLUDE
463         # )
464
465         if(WITH_PYTHON)
466                 set_lib_path(PYLIB "python/lib")
467                 install(
468                         FILES ${PYLIB}/python32.dll
469                         DESTINATION ${TARGETDIR}
470                         CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
471                 )
472
473                 install(
474                         FILES ${PYLIB}/python32_d.dll
475                         DESTINATION ${TARGETDIR}
476                         CONFIGURATIONS Debug
477                 )
478
479                 if(WITH_PYTHON_INSTALL)
480                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
481
482                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
483                         install(
484                                 CODE
485                                 "
486                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
487                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\")
488                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\")
489                                 message(\"done creating dir\")
490                                 "
491                         )
492
493                         install(
494                                 CODE
495                                 "
496                                 if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
497                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
498                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32_d.tar.gz\")
499                                 else()
500                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
501                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
502                                 endif()
503                                 "
504                         )
505
506                         # doesnt work, todo
507                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
508                 endif()
509         endif()
510
511         if(CMAKE_CL_64)
512                 # gettext and png are statically linked on win64
513                 install(
514                         FILES ${LIBDIR}/zlib/lib/zlib.dll
515                         DESTINATION ${TARGETDIR}
516                 )
517         else()
518                 install(
519                         FILES
520                                 ${LIBDIR}/zlib/lib/zlib.dll
521                         DESTINATION ${TARGETDIR}
522                 )
523         endif()
524
525         if(MSVC)
526                 install(
527                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
528                         DESTINATION ${TARGETDIR}
529                 )
530         else()
531                 install(
532                         FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
533                         DESTINATION ${TARGETDIR}
534                 )
535         endif()
536
537         if(WITH_CODEC_FFMPEG)
538                 install(
539                         FILES
540                                 ${LIBDIR}/ffmpeg/lib/avcodec-53.dll
541                                 ${LIBDIR}/ffmpeg/lib/avformat-53.dll
542                                 ${LIBDIR}/ffmpeg/lib/avdevice-53.dll
543                                 ${LIBDIR}/ffmpeg/lib/avutil-51.dll
544                                 ${LIBDIR}/ffmpeg/lib/swscale-2.dll
545                         DESTINATION ${TARGETDIR}
546                 )
547
548         endif()
549
550         if(WITH_CODEC_SNDFILE)
551                 install(
552                         FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
553                         DESTINATION ${TARGETDIR}
554                 )
555         endif()
556
557         if(WITH_OPENAL)
558                 install(
559                         FILES
560                                 ${LIBDIR}/openal/lib/OpenAL32.dll
561                         DESTINATION ${TARGETDIR}
562                 )
563         endif()
564
565         if(WITH_SDL)
566                 if(NOT CMAKE_CL_64)
567                         install(
568                                 FILES ${LIBDIR}/sdl/lib/SDL.dll
569                                 DESTINATION ${TARGETDIR}
570                         )
571                 endif()
572         endif()
573
574         if(NOT CMAKE_CL_64)
575                 install(
576                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
577                         DESTINATION ${TARGETDIR}
578                 )
579         endif()
580                 
581         install( # x86 builds can run on x64 Windows, so this is required at all times
582                 FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
583                 DESTINATION ${TARGETDIR}
584         )       
585
586         if(WITH_OPENIMAGEIO)
587                 set_lib_path(OIIOBIN "openimageio/bin")
588                 install(
589                         FILES
590                                 ${OIIOBIN}/OpenImageIO.dll
591                         DESTINATION ${TARGETDIR}
592                 )
593         endif()
594
595 elseif(APPLE)
596
597         # handy install macro to exclude files, we use \$ escape for the "to"
598         # argument when calling so ${BUILD_TYPE} does not get expanded
599         macro(install_dir from to)
600                 install(
601                         DIRECTORY ${from}
602                         DESTINATION ${to}
603                         PATTERN ".svn" EXCLUDE
604                         PATTERN "*.pyc" EXCLUDE
605                         PATTERN "*.pyo" EXCLUDE
606                         PATTERN "*.orig" EXCLUDE
607                         PATTERN "*.rej" EXCLUDE
608                         PATTERN "__pycache__" EXCLUDE
609                         PATTERN "__MACOSX" EXCLUDE
610                         PATTERN ".DS_Store" EXCLUDE
611                 )
612         endmacro()
613
614         set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
615
616         # setup Info.plist
617         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
618
619         set_target_properties(blender PROPERTIES
620                 MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist
621                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
622                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
623
624
625         # install release and app files
626         install(
627                 FILES ${BLENDER_TEXT_FILES}
628                 DESTINATION ${TARGETDIR}
629         )
630
631         install(
632                 FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo
633                 DESTINATION ${TARGETDIR}/blender.app/Contents
634         )
635
636         install_dir(
637                 ${OSX_APP_SOURCEDIR}/Contents/Resources
638                 \${TARGETDIR}/blender.app/Contents/
639         )
640
641         # python
642         if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE)
643                 # the python zip is first extract as part of the build process,
644                 # and then later installed as part of make install. this is much
645                 # quicker, and means we can easily exclude files on copy
646                 # Not needed for PYTHON_MODULE or WEB_PLUGIN due uses  Pyhon framework
647                 add_custom_target(
648                         extractpyzip
649                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
650
651                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
652
653                 add_custom_command(
654                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
655                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
656                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
657                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
658                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
659
660                 add_dependencies(blender extractpyzip)
661
662                 # copy extracted python files
663                 install_dir(
664                         ${CMAKE_CURRENT_BINARY_DIR}/python
665                         \${TARGETDIR_VER}
666                 )
667
668         endif()
669
670         # install blenderplayer bundle - copy of blender.app above. re-using macros et al
671         # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
672         if(WITH_GAMEENGINE AND WITH_PLAYER)
673                 set(OSX_APP_PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blenderplayer.app)
674                 set(PLAYER_SOURCEINFO ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Info.plist)
675                 set(PLAYER_TARGETDIR_VER ${TARGETDIR}/blenderplayer.app/Contents/MacOS/${BLENDER_VERSION})
676
677
678                 # important to make a clean  install each time else old scripts get loaded.
679                 install(
680                         CODE
681                         "file(REMOVE_RECURSE ${PLAYER_TARGETDIR_VER})"
682                 )
683
684                 install(
685                         FILES ${OSX_APP_PLAYER_SOURCEDIR}/Contents/PkgInfo
686                         DESTINATION ${TARGETDIR}/blenderplayer.app/Contents
687                 )
688
689                 install_dir(
690                         ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Resources
691                         \${TARGETDIR}/blenderplayer.app/Contents/
692                 )
693
694                 # python
695                 if(WITH_PYTHON)
696                         add_custom_command(
697                                 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
698                                 COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
699                                 COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
700                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
701                                 DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
702
703                         # copy extracted python files
704                         install_dir(
705                                 ${CMAKE_CURRENT_BINARY_DIR}/python
706                                 \${PLAYER_TARGETDIR_VER}
707                         )
708                 endif()
709
710         endif()
711 endif()
712
713 # -----------------------------------------------------------------------------
714 # Generic Install, for all targets
715
716
717
718 # install more files specified elsewhere
719 delayed_do_install(${TARGETDIR_VER})
720
721 unset(BLENDER_TEXT_FILES)
722
723
724 # -----------------------------------------------------------------------------
725 # Setup link libs
726
727 add_dependencies(blender makesdna)
728
729 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
730
731 set(BLENDER_LINK_LIBS
732         ${BLENDER_LINK_LIBS}
733         bf_windowmanager
734         bf_render
735 )
736
737 if(WITH_MOD_FLUID)
738         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
739 endif()
740
741 if(WITH_CYCLES)
742         list(APPEND BLENDER_LINK_LIBS
743                 cycles_render
744                 cycles_bvh
745                 cycles_device
746                 cycles_kernel
747                 cycles_util
748                 cycles_subd)
749 endif()
750
751 #if(UNIX)
752         # Sort libraries
753         set(BLENDER_SORTED_LIBS
754                 bf_windowmanager
755
756                 bf_editor_space_api
757                 bf_editor_space_action
758                 bf_editor_space_buttons
759                 bf_editor_space_console
760                 bf_editor_space_file
761                 bf_editor_space_graph
762                 bf_editor_space_image
763                 bf_editor_space_info
764                 bf_editor_space_logic
765                 bf_editor_space_nla
766                 bf_editor_space_node
767                 bf_editor_space_outliner
768                 bf_editor_space_script
769                 bf_editor_space_sequencer
770                 bf_editor_space_time
771                 bf_editor_space_userpref
772                 bf_editor_space_view3d
773                 bf_editor_space_clip
774
775                 bf_editor_text
776                 bf_editor_transform
777                 bf_editor_util
778                 bf_editor_uvedit
779                 bf_editor_curve
780                 bf_editor_armature
781                 bf_editor_gpencil
782                 bf_editor_interface
783                 bf_editor_mesh
784                 bf_editor_metaball
785                 bf_editor_object
786                 bf_editor_physics
787                 bf_editor_render
788                 bf_editor_screen
789                 bf_editor_sculpt_paint
790                 bf_editor_sound
791                 bf_editor_animation
792                 bf_editor_datafiles
793
794                 bf_render
795                 bf_intern_opennl
796                 bf_python
797                 bf_python_ext
798                 bf_python_mathutils
799                 bf_ikplugin
800                 bf_modifiers
801                 bf_blenkernel
802                 bf_nodes
803                 bf_gpu
804                 bf_blenloader
805                 bf_imbuf
806                 bf_blenlib
807                 bf_intern_ghost
808                 bf_intern_string
809                 bf_blenpluginapi
810                 bf_avi
811                 bf_imbuf_cineon
812                 bf_imbuf_openexr
813                 bf_imbuf_dds
814                 bf_collada
815                 bf_intern_bsp
816                 bf_intern_bop
817                 bf_intern_decimate
818                 bf_intern_elbeem
819                 bf_intern_ik
820                 bf_intern_memutil
821                 bf_intern_guardedalloc
822                 bf_intern_ctr
823                 ge_blen_routines
824                 ge_converter
825                 ge_phys_dummy
826                 ge_phys_bullet
827                 bf_intern_smoke
828                 extern_minilzo
829                 extern_lzma
830                 extern_colamd
831                 extern_xdnd
832                 ge_logic_ketsji
833                 extern_recastnavigation
834                 ge_phys_common
835                 ge_logic
836                 ge_rasterizer
837                 ge_oglrasterizer
838                 ge_logic_expressions
839                 ge_scenegraph
840                 ge_logic_network
841                 ge_logic_ngnetwork
842                 extern_bullet
843                 ge_logic_loopbacknetwork
844                 bf_intern_moto
845                 extern_openjpeg
846                 extern_redcode
847                 ge_videotex
848                 bf_rna
849                 bf_dna
850                 bf_blenfont
851                 bf_intern_audaspace
852                 bf_intern_mikktspace
853                 bf_intern_dualcon
854                 bf_intern_cycles
855                 cycles_render
856                 cycles_bvh
857                 cycles_device
858                 cycles_kernel
859                 cycles_util
860                 cycles_subd
861         )
862
863         if(WITH_LIBMV)
864                 list(APPEND BLENDER_SORTED_LIBS extern_libmv)
865         endif()
866
867         if(WITH_MOD_CLOTH_ELTOPO)
868                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
869         endif()
870
871         if(WITH_BUILTIN_GLEW)
872                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
873         endif()
874
875         if(WITH_BINRELOC)
876                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
877         endif()
878
879         if(WITH_CXX_GUARDEDALLOC)
880                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
881         endif()
882
883         if(WITH_IK_ITASC)
884                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
885         endif()
886
887         if(WITH_CODEC_QUICKTIME)
888                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
889         endif()
890
891         if(WITH_CARVE)
892                 list(APPEND BLENDER_SORTED_LIBS extern_carve)
893         endif()
894
895         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
896                 set(REMLIB ${SORTLIB})
897                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
898                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
899                                 set(REMLIB "")
900                         endif()
901                 endforeach()
902                 if(REMLIB)
903                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
904                         list(APPEND REM_MSG ${REMLIB})
905                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
906                 endif()
907         endforeach()
908         if(REM_MSG)
909                 list(SORT REM_MSG)
910                 message(STATUS "Blender Skipping: (${REM_MSG})")
911         endif()
912         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
913
914         unset(SEARCHLIB)
915         unset(SORTLIB)
916         unset(REMLIB)
917         unset(REM_MSG)
918
919 #else()
920 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
921 #endif()
922
923 setup_liblinks(blender)