b1948bfb359cff55c5f0eb9ab2ce57131ad5f187
[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/windowmanager
45 )
46
47 if(WITH_CODEC_QUICKTIME)
48         add_definitions(-DWITH_QUICKTIME)
49 endif()
50
51 if(WITH_IMAGE_OPENEXR)
52         add_definitions(-DWITH_OPENEXR)
53 endif()
54
55 if(WITH_IMAGE_OPENJPEG)
56         add_definitions(-DWITH_OPENJPEG)
57 endif()
58
59 if(WITH_IMAGE_TIFF)
60         add_definitions(-DWITH_TIFF)
61 endif()
62
63 if(WITH_IMAGE_DDS)
64         add_definitions(-DWITH_DDS)
65 endif()
66
67 if(WITH_IMAGE_CINEON)
68         add_definitions(-DWITH_CINEON)
69 endif()
70
71 if(WITH_IMAGE_HDR)
72         add_definitions(-DWITH_HDR)
73 endif()
74
75 if(WITH_PYTHON)
76         blender_include_dirs(../blender/python)
77         add_definitions(-DWITH_PYTHON)
78 endif()
79
80 if(WITH_GAMEENGINE)
81         blender_include_dirs(
82                 ../kernel/gen_messaging
83                 ../kernel/gen_system
84         )
85
86         add_definitions(-DWITH_GAMEENGINE)
87 endif()
88
89 if(NOT WITH_SDL)
90         add_definitions(-DDISABLE_SDL)
91 endif()
92
93 if(WITH_BINRELOC)
94         add_definitions(-DWITH_BINRELOC)
95         blender_include_dirs(${BINRELOC_INC})
96 endif()
97
98 # Setup the exe sources and buildinfo
99 set(SRC
100         creator.c
101 )
102
103 if(WIN32 AND NOT UNIX)
104         list(APPEND SRC
105                 ../icons/winblender.rc
106         )
107 endif()
108
109 if(WITH_BUILDINFO)
110         # --------------------------------------------------------------------------
111         # These defines could all be moved into the header below
112         string(REPLACE " " "\ " BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}")
113         string(REPLACE " " "\ " BUILDINFO_CXXFLAGS "${CMAKE_CXX_FLAGS}")
114         string(REPLACE " " "\ " BUILDINFO_LINKFLAGS "${PLATFORM_LINKFLAGS}")
115         add_definitions(
116                 # # define in header now, else these get out of date on rebuilds.
117                 # -DBUILD_DATE="${BUILD_DATE}"
118                 # -DBUILD_TIME="${BUILD_TIME}"
119                 # -DBUILD_REV="${BUILD_REV}"
120                 -DWITH_BUILDINFO_HEADER # alternative to lines above
121                 -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
122                 -DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
123                 -DBUILD_CFLAGS="${BUILDINFO_CFLAGS}"
124                 -DBUILD_CXXFLAGS="${BUILDINFO_CXXFLAGS}"
125                 -DBUILD_LINKFLAGS="${BUILDINFO_LINKFLAGS}"
126                 -DBUILD_SYSTEM="CMake"
127         )
128
129         # --------------------------------------------------------------------------
130         # write header for values that change each build
131         # note, generaed file is in build dir's source/creator
132         #       except when used as an include path.
133
134         # include the output directory, where the buildinfo.h file is generated
135         include_directories(${CMAKE_BINARY_DIR}/source/creator)
136
137         # a custom target that is always built
138         add_custom_target(buildinfo ALL
139                 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h)
140
141         # creates svnheader.h using cmake script
142         add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h
143                 COMMAND ${CMAKE_COMMAND}
144                 -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
145                 -P ${CMAKE_SOURCE_DIR}/build_files/cmake/buildinfo.cmake)
146
147         # buildinfo.h is a generated file
148         set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h
149                 PROPERTIES GENERATED TRUE
150                 HEADER_FILE_ONLY TRUE)
151                 
152         # add deps below, after adding blender
153         # -------------- done with header values.
154
155         list(APPEND SRC
156                 buildinfo.c
157         )
158 endif()
159
160 # message(STATUS "Configuring blender")
161 if(WITH_PYTHON_MODULE)
162         add_definitions(-DWITH_PYTHON_MODULE)
163
164         # creates ./bin/bpy.so which can be imported as a python module.
165         add_library(blender SHARED ${SRC})
166         set_target_properties(
167                 blender
168                 PROPERTIES
169                          PREFIX ""
170                          OUTPUT_NAME bpy
171                          LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/
172         )
173 else()
174         add_executable(blender ${EXETYPE} ${SRC})
175 endif()
176
177 if(WITH_BUILDINFO)
178         # explicitly say that the executable depends on the buildinfo
179         add_dependencies(blender buildinfo)
180 endif()
181
182 # Post build steps for bundling/packaging.
183
184 set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
185
186 if(WITH_INSTALL)
187
188         if(UNIX)
189                 add_custom_command(TARGET blender
190                         POST_BUILD
191                         MAIN_DEPENDENCY blender
192                         #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/
193                         #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
194                 )
195         endif()
196
197         if(UNIX AND NOT APPLE)
198
199                 if(WITH_INSTALL_PORTABLE)
200                         set(TARGETDIR_VER ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${BLENDER_VERSION})
201                 else()
202                         set(TARGETDIR_VER ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION})
203                 endif()
204
205                 # important to make a clean  install each time
206                 # else old scripts get loaded.
207                 install(
208                         CODE
209                         "file(REMOVE_RECURSE ${TARGETDIR_VER})"
210                 )
211
212                 # there are a few differences between portable and system install
213                 if(WITH_INSTALL_PORTABLE)
214                         install(
215                                 FILES
216                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
217                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/blender.svg
218                                 ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
219                                 DESTINATION ${TARGETDIR}
220                         )
221
222                         install(
223                                 PROGRAMS
224                                 ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
225                                 DESTINATION ${TARGETDIR}
226                         )
227
228                         install(
229                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
230                                 DESTINATION ${TARGETDIR}
231                                 PATTERN ".svn" EXCLUDE
232                         )
233
234                 else()
235                         # main blender binary
236                         install(
237                                 PROGRAMS ${TARGETDIR}/blender
238                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
239                         )
240
241                         # misc files
242                         install(
243                                 FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
244                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
245                         )
246                         install(
247                                 FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/blender.svg
248                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps
249                         )
250                         install(
251                                 PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
252                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
253                         )
254                         install(
255                                 FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
256                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
257                         )
258                         install(
259                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
260                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
261                                 PATTERN ".svn" EXCLUDE
262                         )
263                 endif()
264
265                 install(
266                         FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf
267                         DESTINATION ${TARGETDIR_VER}/config
268                 )
269
270                 if(WITH_INTERNATIONAL)
271                         install(
272                                 FILES ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages
273                                 DESTINATION ${TARGETDIR_VER}/config
274                         )
275
276                         install(
277                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale
278                                 DESTINATION ${TARGETDIR_VER}/datafiles/
279                                 PATTERN ".svn" EXCLUDE
280                         )
281                 endif()
282
283                         install(
284                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
285                                 DESTINATION ${TARGETDIR_VER}/
286                                 PATTERN ".svn" EXCLUDE
287                         )
288
289                 if(WITH_PYTHON)
290                         # install(CODE "message(\"copying blender scripts...\")")
291                         install(
292                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
293                                 DESTINATION ${TARGETDIR_VER}/
294                                 PATTERN ".svn" EXCLUDE
295                                 PATTERN "__pycache__" EXCLUDE
296                         )
297
298                         if(WITH_PYTHON_INSTALL)
299                                 # Copy the systems python into the install directory
300                                 # Scons copy in tools/Blender.py
301                                 # install(CODE "message(\"copying a subset of the systems python...\")")
302                                 install(
303                                         DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
304                                         DESTINATION ${TARGETDIR_VER}/python/lib/
305                                         PATTERN ".svn" EXCLUDE
306                                         PATTERN "__pycache__" EXCLUDE               # ./distutils
307                                         PATTERN "distutils" EXCLUDE                 # ./distutils
308                                         PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
309                                         PATTERN "config" EXCLUDE                    # ./config
310                                         PATTERN "config-*" EXCLUDE                  # ./config-*
311                                         PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
312                                         PATTERN "tkinter" EXCLUDE                   # ./tkinter
313                                         PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
314                                         PATTERN "test" EXCLUDE                      # ./test
315                                         PATTERN "turtledemo" EXCLUDE                # ./turtledemo
316                                 )
317
318                                 # # doesnt work, todo
319                                 # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
320                         endif()
321                 endif()
322         elseif(WIN32)
323                 # notice 'xcopy /Y /H' on .bfont.ttf, this is needed when building over samba
324                 add_custom_command(TARGET blender
325                         POST_BUILD
326                         MAIN_DEPENDENCY blender
327                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\"
328                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\"
329                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\"
330                         COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
331                         COMMAND xcopy /Y /H \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\"
332                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\\\"
333                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\plugins\\\"
334                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\\\"
335                 )
336         
337                 if(CMAKE_CL_64)
338                         # gettext and png are statically linked on win64
339                         add_custom_command(TARGET blender
340                                 POST_BUILD
341                                 MAIN_DEPENDENCY blender
342                                 COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
343                         )
344                 else()
345                         add_custom_command(TARGET blender
346                                 POST_BUILD
347                                 MAIN_DEPENDENCY blender
348                                 COMMAND copy /Y \"${LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\"
349                                 COMMAND copy /Y \"${LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\"
350                                 COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
351                         )
352                 endif()
353                 
354                 
355                 if(MSVC)
356                         add_custom_command(TARGET blender
357                                 POST_BUILD
358                                 MAIN_DEPENDENCY blender
359                                 COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
360                         )
361                 else()
362                         add_custom_command(TARGET blender
363                                 POST_BUILD
364                                 MAIN_DEPENDENCY blender
365                                 COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadGC2.dll\" \"${TARGETDIR}\\\"
366                         )
367                 endif()
368
369                 if(WITH_PYTHON)
370                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
371                         if(NOT CMAKE_BUILD_TYPE) # hack: with multi-configuration generator this is "", so for now copy both python32.dll/zip and python32_d.dll/zip
372                                 add_custom_command(TARGET blender
373                                         POST_BUILD
374                                         MAIN_DEPENDENCY blender
375                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\"
376                                         COMMAND if \"$(ConfigurationName)\" == \"\" copy /Y \"${LIBDIR}\\python\\lib\\python32.dll\" \"${TARGETDIR}\\\"
377                                         COMMAND if \"$(ConfigurationName)\" == \"\" xcopy /E /Y \"${LIBDIR}\\release\\python32\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
378                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" copy /Y \"${LIBDIR}\\python\\lib\\python32_d.dll\" \"${TARGETDIR}\\\"
379                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" xcopy /E /Y \"${LIBDIR}\\release\\python32_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
380                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" copy /Y \"${LIBDIR}\\python\\lib\\python32.dll\" \"${TARGETDIR}\\\"
381                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" xcopy /E /Y \"${LIBDIR}\\release\\python32\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
382                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" copy /Y \"${LIBDIR}\\python\\lib\\python32.dll\" \"${TARGETDIR}\\\"
383                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" xcopy /E /Y \"${LIBDIR}\\release\\python32\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
384                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" copy /Y \"${LIBDIR}\\python\\lib\\python32.dll\" \"${TARGETDIR}\\\"
385                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" xcopy /E /Y \"${LIBDIR}\\release\\python32\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
386                                 )
387                         else()
388                                 if(CMAKE_BUILD_TYPE STREQUAL Debug)
389                                         add_custom_command(TARGET blender
390                                                 POST_BUILD
391                                                 MAIN_DEPENDENCY blender
392                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python32_d.dll\" \"${TARGETDIR}\\\"
393                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python32_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
394                                         )
395                                 else()
396                                         add_custom_command(TARGET blender
397                                                 POST_BUILD
398                                                 MAIN_DEPENDENCY blender
399                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python32.dll\" \"${TARGETDIR}\\\"
400                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python32\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
401                                         )
402                                 endif()
403                         endif()
404                 endif()
405
406                 if(WITH_INTERNATIONAL)
407                         if(CMAKE_CL_64)
408                                 # iconv is statically linked on win64
409                                 add_custom_command(TARGET blender
410                                         POST_BUILD
411                                         MAIN_DEPENDENCY blender
412                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
413                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
414                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
415                                 )
416                         else()
417                                 add_custom_command(TARGET blender
418                                         POST_BUILD
419                                         MAIN_DEPENDENCY blender
420                                         COMMAND copy /Y \"${LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
421                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
422                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
423                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
424                                 )
425                         endif()
426                 endif()
427
428                 if(WITH_CODEC_FFMPEG)
429                         add_custom_command(TARGET blender
430                                 POST_BUILD
431                                 MAIN_DEPENDENCY blender
432                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
433                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
434                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
435                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
436                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
437                         )
438                 endif()
439
440                 if(WITH_CODEC_SNDFILE)
441                         add_custom_command(TARGET blender
442                                 POST_BUILD
443                                 MAIN_DEPENDENCY blender
444                                 COMMAND copy /Y \"${LIBDIR}\\sndfile\\lib\\libsndfile-1.dll\" \"${TARGETDIR}\\\"
445                         )
446                 endif()
447
448                 if(WITH_OPENAL)
449                         add_custom_command(TARGET blender
450                                 POST_BUILD
451                                 MAIN_DEPENDENCY blender
452                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\OpenAL32.dll\" \"${TARGETDIR}\\\"
453                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\wrap_oal.dll\" \"${TARGETDIR}\\\"
454
455                         )
456                 endif()
457
458                 if(WITH_SDL)
459                         if(NOT CMAKE_CL_64)
460                                 add_custom_command(TARGET blender
461                                         POST_BUILD
462                                         MAIN_DEPENDENCY blender
463                                         COMMAND copy /Y \"${LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
464                                 )
465                         endif()
466                 endif()
467
468         elseif(APPLE)
469                 set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
470                 set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
471                 set(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
472
473                 add_custom_command(
474                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
475                         COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
476                         COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
477                         COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
478                         COMMAND cat ${SOURCEINFO} | sed s/VERSION/${BLENDER_VERSION}${BLENDER_VERSION_CHAR}/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
479                         COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
480                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
481                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
482                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
483                 )
484           
485                 if(WITH_INTERNATIONAL)
486                         add_custom_command(
487                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
488                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
489                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
490                         )
491                 endif()
492           
493                 if(WITH_PYTHON)
494                         set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
495                         add_custom_command(
496                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
497                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/
498                                 COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
499                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
500                                 COMMAND find ${TARGETDIR}/blender.app -name '*.py[co]' -prune -exec rm -rf {} '\;'
501                                 COMMAND find ${TARGETDIR}/blender.app -name '__pycache__' -exec rmdir {} '+'
502                         )
503                 endif()   
504         
505                 add_custom_command(
506                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender       
507                         COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
508                         COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
509                         COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;"
510                 )
511         endif()
512
513 endif()
514
515 add_dependencies(blender makesdna)
516
517 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
518
519 set(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
520
521 if(WITH_MOD_FLUID)
522         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
523 endif()
524
525
526 #if(UNIX)
527         # Sort libraries
528         set(BLENDER_SORTED_LIBS
529                 bf_windowmanager
530
531                 bf_editor_space_api
532                 bf_editor_space_action
533                 bf_editor_space_buttons
534                 bf_editor_space_console
535                 bf_editor_space_file
536                 bf_editor_space_graph
537                 bf_editor_space_image
538                 bf_editor_space_info
539                 bf_editor_space_logic
540                 bf_editor_space_nla
541                 bf_editor_space_node
542                 bf_editor_space_outliner
543                 bf_editor_space_script
544                 bf_editor_space_sequencer
545                 bf_editor_space_sound
546                 bf_editor_space_time
547                 bf_editor_space_userpref
548                 bf_editor_space_view3d
549
550                 bf_editor_text
551                 bf_editor_transform
552                 bf_editor_util
553                 bf_editor_uvedit
554                 bf_editor_curve
555                 bf_editor_armature
556                 bf_editor_gpencil
557                 bf_editor_interface
558                 bf_editor_mesh
559                 bf_editor_metaball
560                 bf_editor_object
561                 bf_editor_physics
562                 bf_editor_render
563                 bf_editor_screen
564                 bf_editor_sculpt_paint
565                 bf_editor_sound
566                 bf_editor_animation
567                 bf_editor_datafiles
568
569                 bf_render 
570                 bf_intern_opennl 
571                 bf_python 
572                 bf_python_ext 
573                 bf_ikplugin
574                 bf_modifiers
575                 bf_blenkernel
576                 bf_nodes
577                 bf_gpu
578                 bf_blenloader
579                 bf_blenlib
580                 bf_intern_ghost
581                 bf_intern_string
582                 bf_blenpluginapi 
583                 bf_imbuf 
584                 bf_avi 
585                 bf_imbuf_cineon 
586                 bf_imbuf_openexr 
587                 bf_imbuf_dds
588                 bf_readblenfile
589                 bf_collada
590                 bf_intern_bsp 
591                 bf_intern_bop 
592                 bf_gen_system 
593                 bf_intern_decimate 
594                 bf_intern_elbeem 
595                 bf_intern_ik 
596                 bf_intern_memutil 
597                 bf_intern_guardedalloc 
598                 bf_intern_ctr 
599                 ge_blen_routines 
600                 ge_converter 
601                 ge_phys_dummy
602                 ge_phys_bullet 
603                 bf_intern_smoke
604                 extern_minilzo
605                 extern_lzma
606                 ge_logic_ketsji 
607                 ge_phys_common
608                 ge_logic 
609                 ge_rasterizer 
610                 ge_oglrasterizer 
611                 ge_logic_expressions 
612                 ge_scenegraph 
613                 ge_logic_network 
614                 bf_gen_system
615                 bf_python # duplicate for BPY_driver_exec
616                 ge_logic_ngnetwork 
617                 extern_bullet 
618                 ge_logic_loopbacknetwork 
619                 bf_intern_moto 
620                 extern_glew
621                 extern_openjpeg
622                 extern_redcode
623                 ge_videotex
624                 bf_rna
625                 bf_dna
626                 bf_blenfont
627                 bf_intern_audaspace
628                 bf_intern_mikktspace
629         )
630
631         if(WITH_BINRELOC)
632                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
633         endif()
634
635         if(WITH_CXX_GUARDEDALLOC)
636                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
637         endif()
638
639         if(WITH_IK_ITASC)
640                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
641         endif()
642
643         if(WITH_CODEC_QUICKTIME)
644                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
645         endif()
646
647         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
648                 set(REMLIB ${SORTLIB})
649                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
650                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
651                                 set(REMLIB "")
652                         endif()
653                 endforeach()
654                 if(REMLIB)
655                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
656                         list(APPEND REM_MSG ${REMLIB})
657                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
658                 endif()
659         endforeach()
660         if(REM_MSG)
661                 list(SORT REM_MSG)
662                 message(STATUS "Blender Skipping: (${REM_MSG})")
663         endif()
664         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
665 #else()
666 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
667 #endif()
668
669 setup_liblinks(blender)