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