svn merge ^/trunk/blender -r44204:44213
[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                                 ${LIBDIR}/openal/lib/wrap_oal.dll
562                         DESTINATION ${TARGETDIR}
563                 )
564         endif()
565
566         if(WITH_SDL)
567                 if(NOT CMAKE_CL_64)
568                         install(
569                                 FILES ${LIBDIR}/sdl/lib/SDL.dll
570                                 DESTINATION ${TARGETDIR}
571                         )
572                 endif()
573         endif()
574
575         if(NOT CMAKE_CL_64)
576                 install(
577                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
578                         DESTINATION ${TARGETDIR}
579                 )
580         endif()
581                 
582         install( # x86 builds can run on x64 Windows, so this is required at all times
583                 FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
584                 DESTINATION ${TARGETDIR}
585         )       
586
587         if(WITH_OPENIMAGEIO)
588                 set_lib_path(OIIOBIN "openimageio/bin")
589                 install(
590                         FILES
591                                 ${OIIOBIN}/OpenImageIO.dll
592                         DESTINATION ${TARGETDIR}
593                 )
594         endif()
595
596 elseif(APPLE)
597
598         # handy install macro to exclude files, we use \$ escape for the "to"
599         # argument when calling so ${BUILD_TYPE} does not get expanded
600         macro(install_dir from to)
601                 install(
602                         DIRECTORY ${from}
603                         DESTINATION ${to}
604                         PATTERN ".svn" EXCLUDE
605                         PATTERN "*.pyc" EXCLUDE
606                         PATTERN "*.pyo" EXCLUDE
607                         PATTERN "*.orig" EXCLUDE
608                         PATTERN "*.rej" EXCLUDE
609                         PATTERN "__pycache__" EXCLUDE
610                         PATTERN "__MACOSX" EXCLUDE
611                         PATTERN ".DS_Store" EXCLUDE
612                 )
613         endmacro()
614
615         set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
616
617         # setup Info.plist
618         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
619
620         set_target_properties(blender PROPERTIES
621                 MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist
622                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
623                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
624
625
626         # install release and app files
627         install(
628                 FILES ${BLENDER_TEXT_FILES}
629                 DESTINATION ${TARGETDIR}
630         )
631
632         install(
633                 FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo
634                 DESTINATION ${TARGETDIR}/blender.app/Contents
635         )
636
637         install_dir(
638                 ${OSX_APP_SOURCEDIR}/Contents/Resources
639                 \${TARGETDIR}/blender.app/Contents/
640         )
641
642         # python
643         if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE)
644                 # the python zip is first extract as part of the build process,
645                 # and then later installed as part of make install. this is much
646                 # quicker, and means we can easily exclude files on copy
647                 # Not needed for PYTHON_MODULE or WEB_PLUGIN due uses  Pyhon framework
648                 add_custom_target(
649                         extractpyzip
650                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
651
652                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
653
654                 add_custom_command(
655                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
656                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
657                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
658                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
659                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
660
661                 add_dependencies(blender extractpyzip)
662
663                 # copy extracted python files
664                 install_dir(
665                         ${CMAKE_CURRENT_BINARY_DIR}/python
666                         \${TARGETDIR_VER}
667                 )
668
669         endif()
670
671         # install blenderplayer bundle - copy of blender.app above. re-using macros et al
672         # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
673         if(WITH_GAMEENGINE AND WITH_PLAYER)
674                 set(OSX_APP_PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blenderplayer.app)
675                 set(PLAYER_SOURCEINFO ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Info.plist)
676                 set(PLAYER_TARGETDIR_VER ${TARGETDIR}/blenderplayer.app/Contents/MacOS/${BLENDER_VERSION})
677
678
679                 # important to make a clean  install each time else old scripts get loaded.
680                 install(
681                         CODE
682                         "file(REMOVE_RECURSE ${PLAYER_TARGETDIR_VER})"
683                 )
684
685                 install(
686                         FILES ${OSX_APP_PLAYER_SOURCEDIR}/Contents/PkgInfo
687                         DESTINATION ${TARGETDIR}/blenderplayer.app/Contents
688                 )
689
690                 install_dir(
691                         ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Resources
692                         \${TARGETDIR}/blenderplayer.app/Contents/
693                 )
694
695                 # python
696                 if(WITH_PYTHON)
697                         add_custom_command(
698                                 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
699                                 COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
700                                 COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
701                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
702                                 DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
703
704                         # copy extracted python files
705                         install_dir(
706                                 ${CMAKE_CURRENT_BINARY_DIR}/python
707                                 \${PLAYER_TARGETDIR_VER}
708                         )
709                 endif()
710
711         endif()
712 endif()
713
714 # -----------------------------------------------------------------------------
715 # Generic Install, for all targets
716
717
718
719 # install more files specified elsewhere
720 delayed_do_install(${TARGETDIR_VER})
721
722 unset(BLENDER_TEXT_FILES)
723
724
725 # -----------------------------------------------------------------------------
726 # Setup link libs
727
728 add_dependencies(blender makesdna)
729
730 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
731
732 set(BLENDER_LINK_LIBS
733         ${BLENDER_LINK_LIBS}
734         bf_windowmanager
735         bf_render
736 )
737
738 if(WITH_MOD_FLUID)
739         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
740 endif()
741
742 if(WITH_CYCLES)
743         list(APPEND BLENDER_LINK_LIBS
744                 cycles_render
745                 cycles_bvh
746                 cycles_device
747                 cycles_kernel
748                 cycles_util
749                 cycles_subd)
750 endif()
751
752 #if(UNIX)
753         # Sort libraries
754         set(BLENDER_SORTED_LIBS
755                 bf_windowmanager
756
757                 bf_editor_space_api
758                 bf_editor_space_action
759                 bf_editor_space_buttons
760                 bf_editor_space_console
761                 bf_editor_space_file
762                 bf_editor_space_graph
763                 bf_editor_space_image
764                 bf_editor_space_info
765                 bf_editor_space_logic
766                 bf_editor_space_nla
767                 bf_editor_space_node
768                 bf_editor_space_outliner
769                 bf_editor_space_script
770                 bf_editor_space_sequencer
771                 bf_editor_space_time
772                 bf_editor_space_userpref
773                 bf_editor_space_view3d
774                 bf_editor_space_clip
775
776                 bf_editor_text
777                 bf_editor_transform
778                 bf_editor_util
779                 bf_editor_uvedit
780                 bf_editor_curve
781                 bf_editor_armature
782                 bf_editor_gpencil
783                 bf_editor_interface
784                 bf_editor_mesh
785                 bf_editor_metaball
786                 bf_editor_object
787                 bf_editor_physics
788                 bf_editor_render
789                 bf_editor_screen
790                 bf_editor_sculpt_paint
791                 bf_editor_sound
792                 bf_editor_animation
793                 bf_editor_datafiles
794
795                 bf_render
796                 bf_intern_opennl
797                 bf_python
798                 bf_python_ext
799                 bf_python_mathutils
800                 bf_ikplugin
801                 bf_bmesh
802                 bf_modifiers
803                 bf_blenkernel
804                 bf_nodes
805                 bf_gpu
806                 bf_blenloader
807                 bf_imbuf
808                 bf_blenlib
809                 bf_intern_ghost
810                 bf_intern_string
811                 bf_blenpluginapi
812                 bf_avi
813                 bf_imbuf_cineon
814                 bf_imbuf_openexr
815                 bf_imbuf_dds
816                 bf_collada
817                 bf_intern_bsp
818                 bf_intern_bop
819                 bf_intern_decimate
820                 bf_intern_elbeem
821                 bf_intern_ik
822                 bf_intern_memutil
823                 bf_intern_guardedalloc
824                 bf_intern_ctr
825                 ge_blen_routines
826                 ge_converter
827                 ge_phys_dummy
828                 ge_phys_bullet
829                 bf_intern_smoke
830                 extern_minilzo
831                 extern_lzma
832                 extern_colamd
833                 ge_logic_ketsji
834                 extern_recastnavigation
835                 ge_phys_common
836                 ge_logic
837                 ge_rasterizer
838                 ge_oglrasterizer
839                 ge_logic_expressions
840                 ge_scenegraph
841                 ge_logic_network
842                 ge_logic_ngnetwork
843                 extern_bullet
844                 ge_logic_loopbacknetwork
845                 bf_intern_moto
846                 extern_openjpeg
847                 extern_redcode
848                 ge_videotex
849                 bf_rna
850                 bf_dna
851                 bf_blenfont
852                 bf_intern_audaspace
853                 bf_intern_mikktspace
854                 bf_intern_dualcon
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         if(WITH_CARVE)
893                 list(APPEND BLENDER_SORTED_LIBS extern_carve)
894         endif()
895
896         if(WITH_GHOST_XDND)
897                 list(APPEND BLENDER_SORTED_LIBS extern_xdnd)
898         endif()
899
900         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
901                 set(REMLIB ${SORTLIB})
902                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
903                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
904                                 set(REMLIB "")
905                         endif()
906                 endforeach()
907                 if(REMLIB)
908                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
909                         list(APPEND REM_MSG ${REMLIB})
910                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
911                 endif()
912         endforeach()
913         if(REM_MSG)
914                 list(SORT REM_MSG)
915                 message(STATUS "Blender Skipping: (${REM_MSG})")
916         endif()
917         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
918
919         unset(SEARCHLIB)
920         unset(SORTLIB)
921         unset(REMLIB)
922         unset(REM_MSG)
923
924 #else()
925 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
926 #endif()
927
928 setup_liblinks(blender)