375ddb944f1329fbc7a218702d81b4502e2b8539
[blender-staging.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                 # Local installation, "make install" can be done after this optionally
200                 
201                 add_custom_command(
202                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
203                         COMMAND rm -Rf ${TARGETDIR}/${BLENDER_VERSION}
204                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/
205                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/${BLENDER_VERSION}/
206                 )
207         
208                 if(WITH_INTERNATIONAL)
209                         add_custom_command(
210                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
211                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/${BLENDER_VERSION}/
212                                 COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/${BLENDER_VERSION}/
213                         )
214                 endif()
215         
216                 if(WITH_PYTHON)
217                         add_custom_command(
218                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
219                                 COMMENT "copying blender scripts..."
220                                 COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/${BLENDER_VERSION}/
221                                 COMMAND find ${TARGETDIR} -name "*.py?" -prune -exec rm -rf {} "\;"
222                         )
223                         if(WITH_PYTHON_INSTALL)
224                                 # Copy the systems python into the install directory
225                                 # Scons copy in tools/Blender.py
226                                 add_custom_command(
227                                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
228                                         COMMENT "copying a subset of the systems python..."
229
230                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python # PYTHONPATH and PYTHONHOME is set here
231                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python/lib/
232                                         COMMAND cp -R ${PYTHON_LIBPATH}/python${PYTHON_VERSION} ${TARGETDIR}/${BLENDER_VERSION}/python/lib/
233
234                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/distutils
235                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/lib2to3
236                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/idlelib
237                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/tkinter
238                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/config
239
240                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/site-packages
241                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/site-packages  # python needs it.
242
243                                         COMMAND rm -f ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/lib-dynload/_tkinter.so
244                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "test" -prune -exec rm -rf {} "\;"
245                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "*.py?" -exec rm -rf {} "\;"
246                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "*.so"-exec strip -s {} "\;"
247                                 )
248                         endif()
249                 endif()
250           
251                 add_custom_command(
252                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
253                         COMMAND find ${TARGETDIR} -name .svn -prune -exec rm -rf {} "\;"
254                 )
255         
256         
257                 # Above we bundle a portable distribution in ./bin
258                 # This is an optional "make install" which installs blender on the system.
259                 install(
260                         PROGRAMS ${TARGETDIR}/blender
261                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
262                 )
263
264                 if(WITH_GAMEENGINE AND WITH_PLAYER)
265                         install(
266                                 PROGRAMS ${TARGETDIR}/blenderplayer
267                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
268                         )
269                 endif()
270
271                 install(
272                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
273                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
274                 )
275                 install(
276                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/blender.svg
277                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps
278                 )
279                 install(
280                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
281                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
282                 )
283                 install(
284                         FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
285                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
286                 )
287                 install(
288                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
289                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
290                         PATTERN ".svn" EXCLUDE
291                 )
292                 install(
293                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts/
294                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/scripts
295                         PATTERN ".svn" EXCLUDE
296                         PATTERN "*.pyc" EXCLUDE
297                         PATTERN "__pycache__" EXCLUDE
298                 )
299                 install(
300                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/brushicons/
301                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/datafiles/brushicons
302                         PATTERN ".svn" EXCLUDE
303                 )
304                 if(WITH_INTERNATIONAL)
305                         install(
306                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/
307                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/datafiles/locale
308                                 PATTERN ".svn" EXCLUDE
309                         )
310                 endif()
311                 
312                 # end "make install"
313         
314         elseif(WIN32)
315                 # notice 'xcopy /Y /H' on .bfont.ttf, this is needed when building over samba
316                 add_custom_command(TARGET blender
317                         POST_BUILD
318                         MAIN_DEPENDENCY blender
319                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\"
320                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\"
321                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\"
322                         COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
323                         COMMAND xcopy /Y /H \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\"
324                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\\\"
325                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\plugins\\\"
326                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\\\"
327                 )
328         
329                 if(CMAKE_CL_64)
330                         # gettext and png are statically linked on win64
331                         add_custom_command(TARGET blender
332                                 POST_BUILD
333                                 MAIN_DEPENDENCY blender
334                                 COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
335                         )
336                 else()
337                         add_custom_command(TARGET blender
338                                 POST_BUILD
339                                 MAIN_DEPENDENCY blender
340                                 COMMAND copy /Y \"${LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\"
341                                 COMMAND copy /Y \"${LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\"
342                                 COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
343                         )
344                 endif()
345                 
346                 
347                 if(MSVC)
348                         add_custom_command(TARGET blender
349                                 POST_BUILD
350                                 MAIN_DEPENDENCY blender
351                                 COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
352                         )
353                 else()
354                         add_custom_command(TARGET blender
355                                 POST_BUILD
356                                 MAIN_DEPENDENCY blender
357                                 COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadGC2.dll\" \"${TARGETDIR}\\\"
358                         )
359                 endif()
360
361                 if(WITH_PYTHON)
362                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
363                         if(NOT CMAKE_BUILD_TYPE) # hack: with multi-configuration generator this is "", so for now copy both python31.dll/zip and python31_d.dll/zip
364                                 add_custom_command(TARGET blender
365                                         POST_BUILD
366                                         MAIN_DEPENDENCY blender
367                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\"
368                                         COMMAND if \"$(ConfigurationName)\" == \"\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
369                                         COMMAND if \"$(ConfigurationName)\" == \"\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
370                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
371                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
372                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
373                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
374                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
375                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
376                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
377                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
378                                 )
379                         else()
380                                 if(CMAKE_BUILD_TYPE STREQUAL Debug)
381                                         add_custom_command(TARGET blender
382                                                 POST_BUILD
383                                                 MAIN_DEPENDENCY blender
384                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
385                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
386                                         )
387                                 else()
388                                         add_custom_command(TARGET blender
389                                                 POST_BUILD
390                                                 MAIN_DEPENDENCY blender
391                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
392                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
393                                         )
394                                 endif()
395                         endif()
396                 endif()
397
398                 if(WITH_INTERNATIONAL)
399                         if(CMAKE_CL_64)
400                                 # iconv is statically linked on win64
401                                 add_custom_command(TARGET blender
402                                         POST_BUILD
403                                         MAIN_DEPENDENCY blender
404                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
405                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
406                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
407                                 )
408                         else()
409                                 add_custom_command(TARGET blender
410                                         POST_BUILD
411                                         MAIN_DEPENDENCY blender
412                                         COMMAND copy /Y \"${LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
413                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
414                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
415                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
416                                 )
417                         endif()
418                 endif()
419
420                 if(WITH_CODEC_FFMPEG)
421                         add_custom_command(TARGET blender
422                                 POST_BUILD
423                                 MAIN_DEPENDENCY blender
424                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
425                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
426                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
427                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
428                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
429                         )
430                 endif()
431
432                 if(WITH_CODEC_SNDFILE)
433                         add_custom_command(TARGET blender
434                                 POST_BUILD
435                                 MAIN_DEPENDENCY blender
436                                 COMMAND copy /Y \"${LIBDIR}\\sndfile\\lib\\libsndfile-1.dll\" \"${TARGETDIR}\\\"
437                         )
438                 endif()
439
440                 if(WITH_OPENAL)
441                         add_custom_command(TARGET blender
442                                 POST_BUILD
443                                 MAIN_DEPENDENCY blender
444                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\OpenAL32.dll\" \"${TARGETDIR}\\\"
445                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\wrap_oal.dll\" \"${TARGETDIR}\\\"
446
447                         )
448                 endif()
449
450                 if(WITH_SDL)
451                         if(NOT CMAKE_CL_64)
452                                 add_custom_command(TARGET blender
453                                         POST_BUILD
454                                         MAIN_DEPENDENCY blender
455                                         COMMAND copy /Y \"${LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
456                                 )
457                         endif()
458                 endif()
459
460         elseif(APPLE)
461                 set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
462                 set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
463                 set(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
464
465                 add_custom_command(
466                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
467                         COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
468                         COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
469                         COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
470                         COMMAND cat ${SOURCEINFO} | sed s/VERSION/${BLENDER_VERSION}${BLENDER_VERSION_CHAR}/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
471                         COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
472                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
473                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
474                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
475                 )
476           
477                 if(WITH_INTERNATIONAL)
478                         add_custom_command(
479                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
480                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
481                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
482                         )
483                 endif()
484           
485                 if(WITH_PYTHON)
486                         set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
487                         add_custom_command(
488                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
489                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/
490                                 COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
491                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
492                                 COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;"
493                         )
494                 endif()   
495         
496                 add_custom_command(
497                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender       
498                         COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
499                         COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
500                                         COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;"
501                 )
502         endif()
503
504 endif()
505
506 add_dependencies(blender makesdna)
507
508 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
509
510 set(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
511
512 if(WITH_MOD_FLUID)
513         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
514 endif()
515
516
517 #if(UNIX)
518         # Sort libraries
519         set(BLENDER_SORTED_LIBS
520                 bf_windowmanager
521
522                 bf_editor_space_api
523                 bf_editor_space_action
524                 bf_editor_space_buttons
525                 bf_editor_space_console
526                 bf_editor_space_file
527                 bf_editor_space_graph
528                 bf_editor_space_image
529                 bf_editor_space_info
530                 bf_editor_space_logic
531                 bf_editor_space_nla
532                 bf_editor_space_node
533                 bf_editor_space_outliner
534                 bf_editor_space_script
535                 bf_editor_space_sequencer
536                 bf_editor_space_sound
537                 bf_editor_space_time
538                 bf_editor_space_userpref
539                 bf_editor_space_view3d
540
541                 bf_editor_text
542                 bf_editor_transform
543                 bf_editor_util
544                 bf_editor_uvedit
545                 bf_editor_curve
546                 bf_editor_armature
547                 bf_editor_gpencil
548                 bf_editor_interface
549                 bf_editor_mesh
550                 bf_editor_metaball
551                 bf_editor_object
552                 bf_editor_physics
553                 bf_editor_render
554                 bf_editor_screen
555                 bf_editor_sculpt_paint
556                 bf_editor_sound
557                 bf_editor_animation
558                 bf_editor_datafiles
559
560                 bf_render 
561                 bf_intern_opennl 
562                 bf_python 
563                 bf_python_ext 
564                 bf_ikplugin
565                 bf_modifiers
566                 bf_blenkernel
567                 bf_nodes
568                 bf_gpu
569                 bf_blenloader
570                 bf_blenlib
571                 bf_intern_ghost
572                 bf_intern_string
573                 bf_blenpluginapi 
574                 bf_imbuf 
575                 bf_avi 
576                 bf_imbuf_cineon 
577                 bf_imbuf_openexr 
578                 bf_imbuf_dds
579                 bf_readblenfile
580                 bf_collada
581                 bf_intern_bsp 
582                 bf_intern_bop 
583                 bf_gen_system 
584                 bf_intern_decimate 
585                 bf_intern_elbeem 
586                 bf_intern_ik 
587                 bf_intern_memutil 
588                 bf_intern_guardedalloc 
589                 bf_intern_ctr 
590                 ge_blen_routines 
591                 ge_converter 
592                 ge_phys_dummy
593                 ge_phys_bullet 
594                 bf_intern_smoke
595                 extern_minilzo
596                 extern_lzma
597                 ge_logic_ketsji 
598                 ge_phys_common
599                 ge_logic 
600                 ge_rasterizer 
601                 ge_oglrasterizer 
602                 ge_logic_expressions 
603                 ge_scenegraph 
604                 ge_logic_network 
605                 bf_gen_system
606                 bf_python # duplicate for BPY_driver_exec
607                 ge_logic_ngnetwork 
608                 extern_bullet 
609                 ge_logic_loopbacknetwork 
610                 bf_intern_moto 
611                 extern_glew
612                 extern_openjpeg
613                 extern_redcode
614                 ge_videotex
615                 bf_rna
616                 bf_dna
617                 bf_blenfont
618                 bf_intern_audaspace
619                 bf_intern_mikktspace
620         )
621
622         if(WITH_BINRELOC)
623                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
624         endif()
625
626         if(WITH_CXX_GUARDEDALLOC)
627                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
628         endif()
629
630         if(WITH_IK_ITASC)
631                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
632         endif()
633
634         if(WITH_CODEC_QUICKTIME)
635                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
636         endif()
637
638         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
639                 set(REMLIB ${SORTLIB})
640                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
641                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
642                                 set(REMLIB "")
643                         endif()
644                 endforeach()
645                 if(REMLIB)
646                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
647                         list(APPEND REM_MSG ${REMLIB})
648                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
649                 endif()
650         endforeach()
651         if(REM_MSG)
652                 list(SORT REM_MSG)
653                 message(STATUS "Blender Skipping: (${REM_MSG})")
654         endif()
655         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
656 #else()
657 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
658 #endif()
659
660 setup_liblinks(blender)