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