Merged changes in the trunk up to revision 36551.
[blender.git] / source / creator / CMakeLists.txt
1 # -*- mode: cmake; indent-tabs-mode: t; -*-
2 # $Id$
3 # ***** BEGIN GPL LICENSE BLOCK *****
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #
19 # The Original Code is Copyright (C) 2006, Blender Foundation
20 # All rights reserved.
21 #
22 # The Original Code is: all of this file.
23 #
24 # Contributor(s): Jacques Beaurain.
25 #
26 # ***** END GPL LICENSE BLOCK *****
27
28 # So BUILDINFO and BLENDERPATH strings are automatically quoted
29 cmake_policy(SET CMP0005 NEW)
30
31 setup_libdirs()
32
33 blender_include_dirs(
34         ../../intern/guardedalloc
35         ../blender/blenlib
36         ../blender/blenkernel
37         ../blender/blenloader
38         ../blender/editors/include
39         ../blender/makesrna
40         ../blender/imbuf
41         ../blender/render/extern/include
42         ../blender/makesdna
43         ../blender/gpu
44         ../blender/freestyle
45         ../blender/windowmanager
46 )
47
48 if(WITH_CODEC_QUICKTIME)
49         add_definitions(-DWITH_QUICKTIME)
50 endif()
51
52 if(WITH_IMAGE_OPENEXR)
53         add_definitions(-DWITH_OPENEXR)
54 endif()
55
56 if(WITH_IMAGE_OPENJPEG)
57         add_definitions(-DWITH_OPENJPEG)
58 endif()
59
60 if(WITH_IMAGE_TIFF)
61         add_definitions(-DWITH_TIFF)
62 endif()
63
64 if(WITH_IMAGE_DDS)
65         add_definitions(-DWITH_DDS)
66 endif()
67
68 if(WITH_IMAGE_CINEON)
69         add_definitions(-DWITH_CINEON)
70 endif()
71
72 if(WITH_IMAGE_HDR)
73         add_definitions(-DWITH_HDR)
74 endif()
75
76 if(WITH_PYTHON)
77         blender_include_dirs(../blender/python)
78         add_definitions(-DWITH_PYTHON)
79
80         if(WITH_PYTHON_SECURITY)
81                 add_definitions(-DWITH_PYTHON_SECURITY)
82         endif()
83 endif()
84
85 if(WITH_GAMEENGINE)
86         blender_include_dirs(../gameengine/BlenderRoutines)
87
88         add_definitions(-DWITH_GAMEENGINE)
89 endif()
90
91 if(NOT WITH_SDL)
92         add_definitions(-DDISABLE_SDL)
93 endif()
94
95 if(WITH_BINRELOC)
96         add_definitions(-DWITH_BINRELOC)
97         blender_include_dirs(${BINRELOC_INC})
98 endif()
99
100 # Setup the exe sources and buildinfo
101 set(SRC
102         creator.c
103 )
104
105 # MSVC 2010 gives linking errors with the manifest
106 if(WIN32 AND NOT UNIX)
107         string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
108         string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
109         string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
110         if(MINGW)
111                 add_definitions(
112                         -DWINDRES
113                         -DBLEN_VER_RC_STR_M=${BLENDER_VERSION}
114                         -DBLEN_VER_RC_1=${bver1}
115                         -DBLEN_VER_RC_2=${bver2}
116                         -DBLEN_VER_RC_3=${bver3}
117                         -DBLEN_VER_RC_4=0
118                 )
119         else()
120                 add_definitions(
121                         -DBLEN_VER_RC_STR=${BLENDER_VERSION}
122                         -DBLEN_VER_RC_1=${bver1}
123                         -DBLEN_VER_RC_2=${bver2}
124                         -DBLEN_VER_RC_3=${bver3}
125                         -DBLEN_VER_RC_4=0
126                 )
127         endif()
128         
129
130         list(APPEND SRC
131                 ../icons/winblender.rc
132         )
133 endif()
134
135 if(WITH_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 # install target
232 if(UNIX AND NOT APPLE)
233
234         if(WITH_INSTALL_PORTABLE)
235                 set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
236         else()
237                 set(TARGETDIR_VER ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION})
238         endif()
239
240         # important to make a clean  install each time
241         # else old scripts get loaded.
242         install(
243                 CODE
244                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
245         )
246
247         # message after building.
248         add_custom_command(
249                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
250                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${TARGETDIR_VER}'
251         )
252
253         # there are a few differences between portable and system install
254         if(WITH_INSTALL_PORTABLE)
255                 install(
256                         FILES
257                         ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
258                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
259                         ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
260                         DESTINATION ${TARGETDIR}
261                 )
262
263                 install(
264                         PROGRAMS
265                         ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
266                         DESTINATION ${TARGETDIR}
267                 )
268
269                 install(
270                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
271                         DESTINATION ${TARGETDIR}
272                         PATTERN ".svn" EXCLUDE
273                 )
274
275         else()
276                 # main blender binary
277                 install(
278                         PROGRAMS ${TARGETDIR}/blender
279                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
280                 )
281
282                 if(WITH_GAMEENGINE AND WITH_PLAYER)
283                         install(
284                                 PROGRAMS ${TARGETDIR}/blenderplayer
285                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
286                         )
287                 endif()
288
289                 # misc files
290                 install(
291                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
292                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
293                 )
294                 install(
295                         DIRECTORY
296                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/16x16
297                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/22x22
298                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/24x24
299                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/32x32
300                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48
301                                         ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256
302                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/
303                         PATTERN ".svn" EXCLUDE
304                         PATTERN "*.svg" EXCLUDE
305                 )
306                 install(
307                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
308                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps
309                 )
310                 install(
311                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
312                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
313                 )
314                 install(
315                         FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
316                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
317                 )
318                 install(
319                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
320                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
321                         PATTERN ".svn" EXCLUDE
322                 )
323         endif()
324
325         install(
326                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
327                 DESTINATION ${TARGETDIR_VER}/config
328         )
329
330         if(WITH_INTERNATIONAL)
331                 install(
332                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
333                         DESTINATION ${TARGETDIR_VER}/config
334                 )
335
336                 install(
337                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
338                         DESTINATION ${TARGETDIR_VER}/datafiles/
339                         PATTERN ".svn" EXCLUDE
340                 )
341         endif()
342
343                 # plugins in blender 2.5 don't work at the moment.
344                 #
345                 # install(
346                 #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
347                 #       DESTINATION ${TARGETDIR_VER}/
348                 #       PATTERN ".svn" EXCLUDE
349                 # )
350
351         if(WITH_PYTHON)
352                 # install(CODE "message(\"copying blender scripts...\")")
353                 install(
354                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
355                         DESTINATION ${TARGETDIR_VER}/
356                         PATTERN ".svn" EXCLUDE
357                         PATTERN "__pycache__" EXCLUDE
358                 )
359
360                 if(WITH_PYTHON_INSTALL)
361                         # Copy the systems python into the install directory
362                         # Scons copy in tools/Blender.py
363                         # install(CODE "message(\"copying a subset of the systems python...\")")
364                         install(
365                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
366                                 DESTINATION ${TARGETDIR_VER}/python/lib/
367                                 PATTERN ".svn" EXCLUDE
368                                 PATTERN "__pycache__" EXCLUDE               # ./distutils
369                                 PATTERN "distutils" EXCLUDE                 # ./distutils
370                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
371                                 PATTERN "config" EXCLUDE                    # ./config
372                                 PATTERN "config-*" EXCLUDE                  # ./config-*
373                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
374                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
375                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
376                                 PATTERN "test" EXCLUDE                      # ./test
377                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
378                         )
379
380                         # # doesnt work, todo
381                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
382                 endif()
383         endif()
384 elseif(WIN32)
385
386         set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
387
388         install(  # same as linux!, deduplicate
389                 CODE
390                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
391         )
392
393         install(  # same as linux!, deduplicate
394                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
395                 DESTINATION ${TARGETDIR}/
396                 PATTERN ".svn" EXCLUDE
397         )
398
399         install(  # same as linux!, deduplicate
400                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
401                 DESTINATION ${TARGETDIR_VER}/config
402         )
403
404         if(WITH_INTERNATIONAL) # same as linux!, deduplicate
405                 install(
406                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
407                         DESTINATION ${TARGETDIR_VER}/config
408                 )
409                 install(
410                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
411                         DESTINATION ${TARGETDIR_VER}/datafiles/
412                         PATTERN ".svn" EXCLUDE
413                 )
414
415                 if(NOT CMAKE_CL_64)
416                         install(
417                                 FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
418                                 DESTINATION ${TARGETDIR}/
419                         )
420
421                         install(
422                                 FILES ${LIBDIR}/iconv/lib/iconv.dll
423                                 DESTINATION ${TARGETDIR}/
424                         )
425                 endif()
426         endif()
427
428         install( # same as linux!, deduplicate
429                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/
430                 DESTINATION ${TARGETDIR_VER}/datafiles/locale
431                 PATTERN ".svn" EXCLUDE
432         )
433
434         # plugins in blender 2.5 don't work at the moment.
435         #
436         # install(
437         #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
438         #       DESTINATION ${TARGETDIR_VER}/
439         #       PATTERN ".svn" EXCLUDE
440         # )
441
442         if(WITH_PYTHON)
443                 # install(CODE "message(\"copying blender scripts...\")")
444                 install(  # same as linux!, deduplicate
445                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
446                         DESTINATION ${TARGETDIR_VER}/
447                         PATTERN ".svn" EXCLUDE
448                         PATTERN "__pycache__" EXCLUDE
449                 )
450
451                 # TODO, multiple targets?
452                 install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS Release)
453                 install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS RelWithDebInfo)
454                 install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS MinSizeRel)
455
456                 install(
457                         FILES ${LIBDIR}/python/lib/python32_d.dll
458                         DESTINATION ${TARGETDIR}/
459                         CONFIGURATIONS Debug
460                 )
461
462                 if(WITH_PYTHON_INSTALL)
463                         #~ # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
464
465                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
466                         install(CODE "
467                         message(\"creating ${TARGETDIR_VER}/python/lib\")
468                         file(MAKE_DIRECTORY ${TARGETDIR_VER}/python/)
469                         file(MAKE_DIRECTORY ${TARGETDIR_VER}/python/lib/)
470                         message(\"done creating dir\")
471                         ")
472
473                         install(
474                                 CODE
475                                 "
476                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
477                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
478                                 "
479                                 CONFIGURATIONS Release
480                         )
481                         install(
482                                 CODE
483                                 "
484                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
485                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
486                                 "
487                                 CONFIGURATIONS RelWithDebInfo
488                         )
489                         install(
490                                 CODE
491                                 "
492                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
493                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
494                                 "
495                                 CONFIGURATIONS MinSizeRel
496                         )
497                         install(
498                                 CODE
499                                 "
500                                 execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\"
501                                         \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32_d.tar.gz\")
502                                 "
503                                 CONFIGURATIONS Debug
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}/png/lib/libpng.dll
521                         ${LIBDIR}/zlib/lib/zlib.dll
522                         DESTINATION ${TARGETDIR}/
523                 )
524         endif()
525
526         if(MSVC)
527                 install(
528                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
529                         DESTINATION ${TARGETDIR}/
530                 )
531         else()
532                 install(
533                         FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
534                         DESTINATION ${TARGETDIR}/
535                 )
536         endif()
537
538         if(WITH_CODEC_FFMPEG)
539                 install(
540                         FILES
541                         ${LIBDIR}/ffmpeg/lib/avcodec-52.dll
542                         ${LIBDIR}/ffmpeg/lib/avformat-52.dll
543                         ${LIBDIR}/ffmpeg/lib/avdevice-52.dll
544                         ${LIBDIR}/ffmpeg/lib/avutil-50.dll
545                         ${LIBDIR}/ffmpeg/lib/swscale-0.dll
546                         DESTINATION ${TARGETDIR}/
547                 )
548
549         endif()
550
551         if(WITH_CODEC_SNDFILE)
552                 install(
553                         FILES
554                         ${LIBDIR}/sndfile/lib/libsndfile-1.dll
555                         DESTINATION ${TARGETDIR}/
556                 )
557         endif()
558
559         if(WITH_OPENAL)
560                 install(
561                         FILES
562                         ${LIBDIR}/openal/lib/OpenAL32.dll
563                         ${LIBDIR}/openal/lib/wrap_oal.dll
564                         DESTINATION ${TARGETDIR}/
565                 )
566         endif()
567
568         if(WITH_SDL)
569                 if(NOT CMAKE_CL_64)
570                         install(
571                                 FILES
572                                 ${LIBDIR}/sdl/lib/SDL.dll
573                                 DESTINATION ${TARGETDIR}/
574                         )
575                 endif()
576         endif()
577
578     if(NOT CMAKE_CL_64)
579                 install(
580                         FILES
581                 ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
582                 DESTINATION ${TARGETDIR}/
583             )
584     else()
585                 install(
586                         FILES
587                 ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
588                 DESTINATION ${TARGETDIR}/
589             )
590     endif()
591
592 elseif(APPLE)
593         set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
594         set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
595         set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
596
597         # setup Info.plist
598         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
599
600         set_target_properties(blender PROPERTIES
601                 MACOSX_BUNDLE_INFO_PLIST ${SOURCEINFO}
602                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
603                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
604
605         # important to make a clean  install each time else old scripts get loaded.
606         install(
607                 CODE
608                 "file(REMOVE_RECURSE ${TARGETDIR_VER})"
609         )
610
611         # message after building.
612         add_custom_command(
613                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
614                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${TARGETDIR_VER}'
615         )
616
617         # handy install macro to exclude files, we use \$ escape for the "to"
618         # argument when calling so ${BUILD_TYPE} does not get expanded
619         macro(install_dir from to)
620                 install(
621                         DIRECTORY ${from}
622                         DESTINATION ${to}
623                         PATTERN ".svn" EXCLUDE
624                         PATTERN "*.pyc" EXCLUDE
625                         PATTERN "*.pyo" EXCLUDE
626                         PATTERN "*.orig" EXCLUDE
627                         PATTERN "*.rej" EXCLUDE
628                         PATTERN "__pycache__" EXCLUDE
629                         PATTERN "__MACOSX" EXCLUDE
630                         PATTERN ".DS_Store" EXCLUDE
631                 )
632         endmacro()
633
634         # install release and app files
635         install_dir(
636                 ${CMAKE_SOURCE_DIR}/release/text/
637                 \${TARGETDIR}
638         )
639
640         install(
641                 FILES ${SOURCEDIR}/Contents/PkgInfo
642                 DESTINATION ${TARGETDIR}/blender.app/Contents/
643         )
644
645         install_dir(
646                 ${SOURCEDIR}/Contents/Resources
647                 \${TARGETDIR}/blender.app/Contents/
648         )
649
650         install(
651                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
652                 DESTINATION ${TARGETDIR_VER}/datafiles
653         )
654
655         # localization
656         if(WITH_INTERNATIONAL)
657                 install(
658                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
659                         DESTINATION ${TARGETDIR_VER}/datafiles
660                 )
661
662                 install_dir(
663                         ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/
664                         \${TARGETDIR_VER}/datafiles/locale
665                 )
666         endif()
667
668         # python
669         if(WITH_PYTHON)
670                 # the python zip is first extract as part of the build process,
671                 # and then later installed as part of make install. this is much
672                 # quicker, and means we can easily exclude files on copy
673                 add_custom_target(
674                         extractpyzip
675                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
676
677                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
678                         
679                 add_custom_command(
680                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
681                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
682                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
683                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
684                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
685                 
686                 add_dependencies(blender extractpyzip)
687
688                 # copy extracted python files
689                 install_dir(
690                         ${CMAKE_CURRENT_BINARY_DIR}/python
691                         \${TARGETDIR_VER}
692                 )
693
694                 # copy scripts
695                 install_dir(
696                         ${CMAKE_SOURCE_DIR}/release/scripts
697                         \${TARGETDIR_VER}
698                 )
699         endif()
700 endif()
701
702 add_dependencies(blender makesdna)
703
704 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
705
706 set(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
707
708 if(WITH_MOD_FLUID)
709         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
710 endif()
711
712
713 #if(UNIX)
714         # Sort libraries
715         set(BLENDER_SORTED_LIBS
716                 bf_windowmanager
717
718                 bf_editor_space_api
719                 bf_editor_space_action
720                 bf_editor_space_buttons
721                 bf_editor_space_console
722                 bf_editor_space_file
723                 bf_editor_space_graph
724                 bf_editor_space_image
725                 bf_editor_space_info
726                 bf_editor_space_logic
727                 bf_editor_space_nla
728                 bf_editor_space_node
729                 bf_editor_space_outliner
730                 bf_editor_space_script
731                 bf_editor_space_sequencer
732                 bf_editor_space_sound
733                 bf_editor_space_time
734                 bf_editor_space_userpref
735                 bf_editor_space_view3d
736
737                 bf_editor_text
738                 bf_editor_transform
739                 bf_editor_util
740                 bf_editor_uvedit
741                 bf_editor_curve
742                 bf_editor_armature
743                 bf_editor_gpencil
744                 bf_editor_interface
745                 bf_editor_mesh
746                 bf_editor_metaball
747                 bf_editor_object
748                 bf_editor_physics
749                 bf_editor_render
750                 bf_editor_screen
751                 bf_editor_sculpt_paint
752                 bf_editor_sound
753                 bf_editor_animation
754                 bf_editor_datafiles
755
756                 bf_render
757                 bf_intern_opennl
758                 bf_python
759                 bf_python_ext
760                 bf_freestyle
761                 bf_ikplugin
762                 bf_modifiers
763                 bf_blenkernel
764                 bf_nodes
765                 bf_gpu
766                 bf_blenloader
767                 bf_blenlib
768                 bf_intern_ghost
769                 bf_intern_string
770                 bf_blenpluginapi
771                 bf_imbuf
772                 bf_avi
773                 bf_imbuf_cineon
774                 bf_imbuf_openexr
775                 bf_imbuf_dds
776                 bf_readblenfile
777                 bf_collada
778                 bf_intern_bsp
779                 bf_intern_bop
780                 bf_intern_decimate
781                 bf_intern_elbeem
782                 bf_intern_ik
783                 bf_intern_memutil
784                 bf_intern_guardedalloc
785                 bf_intern_ctr
786                 ge_blen_routines
787                 ge_converter
788                 ge_phys_dummy
789                 ge_phys_bullet
790                 bf_intern_smoke
791                 extern_minilzo
792                 extern_lzma
793                 ge_logic_ketsji
794                 ge_phys_common
795                 ge_logic
796                 ge_rasterizer
797                 ge_oglrasterizer
798                 ge_logic_expressions
799                 ge_scenegraph
800                 ge_logic_network
801                 bf_python # duplicate for BPY_driver_exec
802                 ge_logic_ngnetwork
803                 extern_bullet
804                 ge_logic_loopbacknetwork
805                 bf_intern_moto
806                 extern_openjpeg
807                 extern_redcode
808                 ge_videotex
809                 bf_rna
810                 bf_dna
811                 bf_blenfont
812                 bf_intern_audaspace
813                 bf_intern_mikktspace
814         )
815
816     if(WITH_MOD_CLOTH_ELTOPO)
817                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
818     endif()
819
820     if(WITH_BUILTIN_GLEW)
821                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
822     endif()
823
824         if(WITH_BINRELOC)
825                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
826         endif()
827
828         if(WITH_CXX_GUARDEDALLOC)
829                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
830         endif()
831
832         if(WITH_IK_ITASC)
833                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
834         endif()
835
836         if(WITH_CODEC_QUICKTIME)
837                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
838         endif()
839
840         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
841                 set(REMLIB ${SORTLIB})
842                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
843                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
844                                 set(REMLIB "")
845                         endif()
846                 endforeach()
847                 if(REMLIB)
848                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
849                         list(APPEND REM_MSG ${REMLIB})
850                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
851                 endif()
852         endforeach()
853         if(REM_MSG)
854                 list(SORT REM_MSG)
855                 message(STATUS "Blender Skipping: (${REM_MSG})")
856         endif()
857         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
858 #else()
859 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
860 #endif()
861
862 setup_liblinks(blender)