5e33976cb945972ed2404245839f60bfd0ec47c3
[blender-staging.git] / source / creator / CMakeLists.txt
1 # $Id$
2 # ***** BEGIN GPL LICENSE BLOCK *****
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18 # The Original Code is Copyright (C) 2006, Blender Foundation
19 # All rights reserved.
20 #
21 # The Original Code is: all of this file.
22 #
23 # Contributor(s): Jacques Beaurain.
24 #
25 # ***** END GPL LICENSE BLOCK *****
26
27 # So BUILDINFO and BLENDERPATH strings are automatically quoted
28 CMAKE_POLICY(SET CMP0005 NEW)
29
30 SETUP_LIBDIRS()
31
32 INCLUDE_DIRECTORIES(
33         ../../intern/guardedalloc
34         ../blender/blenlib
35         ../blender/blenkernel
36         ../blender/editors/include
37         ../blender/makesrna
38         ../blender/imbuf
39         ../blender/render/extern/include
40         ../blender/makesdna
41         ../blender/gpu
42         ../blender/windowmanager
43 )
44
45 IF(WIN32)
46         INCLUDE_DIRECTORIES(${PTHREADS_INC})
47 ENDIF(WIN32)
48
49 IF(WITH_QUICKTIME)
50         ADD_DEFINITIONS(-DWITH_QUICKTIME)
51 ENDIF(WITH_QUICKTIME)
52
53 IF(WITH_IMAGE_OPENEXR)
54         ADD_DEFINITIONS(-DWITH_OPENEXR)
55 ENDIF(WITH_IMAGE_OPENEXR)
56
57 IF(WITH_IMAGE_TIFF)
58         ADD_DEFINITIONS(-DWITH_TIFF)
59 ENDIF(WITH_IMAGE_TIFF)
60
61 IF(WITH_IMAGE_DDS)
62         ADD_DEFINITIONS(-DWITH_DDS)
63 ENDIF(WITH_IMAGE_DDS)
64
65 IF(WITH_IMAGE_CINEON)
66         ADD_DEFINITIONS(-DWITH_CINEON)
67 ENDIF(WITH_IMAGE_CINEON)
68
69 IF(WITH_IMAGE_HDR)
70         ADD_DEFINITIONS(-DWITH_HDR)
71 ENDIF(WITH_IMAGE_HDR)
72
73 IF(WITH_PYTHON)
74         INCLUDE_DIRECTORIES(../blender/python)
75         ADD_DEFINITIONS(-DWITH_PYTHON)
76 ENDIF(WITH_PYTHON)
77
78 IF(WITH_GAMEENGINE)
79         INCLUDE_DIRECTORIES(
80                 ../kernel/gen_messaging
81                 ../kernel/gen_system
82         )
83
84         ADD_DEFINITIONS(-DWITH_GAMEENGINE)
85 ENDIF(WITH_GAMEENGINE)
86
87 IF(NOT WITH_SDL)
88         ADD_DEFINITIONS(-DDISABLE_SDL)
89 ENDIF(NOT WITH_SDL)
90
91 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
92         ADD_DEFINITIONS(-DWITH_BINRELOC)
93         INCLUDE_DIRECTORIES(${BINRELOC_INC})
94 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
95
96 # Setup the exe sources and buildinfo
97 SET(EXESRC creator.c)
98
99 IF(WIN32)
100         LIST(APPEND EXESRC ../icons/winblender.rc)
101 ENDIF(WIN32)
102
103 IF(WITH_BUILDINFO)
104         STRING(REPLACE " " "\ " BUILDINFO_CFLAGS ${CMAKE_C_FLAGS})
105         STRING(REPLACE " " "\ " BUILDINFO_CXXFLAGS ${CMAKE_CXX_FLAGS})
106         STRING(REPLACE " " "\ " BUILDINFO_LINKFLAGS ${PLATFORM_LINKFLAGS})
107         ADD_DEFINITIONS(
108                 -DBUILD_DATE="${BUILD_DATE}"
109                 -DBUILD_TIME="${BUILD_TIME}"
110                 -DBUILD_REV="${BUILD_REV}"
111                 -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
112                 -DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
113                 -DBUILD_CFLAGS="${BUILDINFO_CFLAGS}"
114                 -DBUILD_CXXFLAGS="${BUILDINFO_CXXFLAGS}"
115                 -DBUILD_LINKFLAGS="${BUILDINFO_LINKFLAGS}"
116                 -DBUILD_SYSTEM="CMake"
117         )
118
119         LIST(APPEND EXESRC buildinfo.c)
120 ENDIF(WITH_BUILDINFO)
121
122 MESSAGE(STATUS "Configuring blender")
123
124 ADD_EXECUTABLE(blender ${EXETYPE} ${EXESRC})
125
126 # Post build steps for bundling/packaging.
127
128 SET(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
129
130 IF(WITH_INSTALL)
131
132         IF(UNIX)
133                 ADD_CUSTOM_COMMAND(TARGET blender
134                         POST_BUILD
135                         MAIN_DEPENDENCY blender
136                         #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/
137                         #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/
138                 )
139         ENDIF(UNIX)
140
141         IF(UNIX AND NOT APPLE)
142                 
143                 # Local installation, "make install" can be done after this optionally
144                 
145                 ADD_CUSTOM_COMMAND(
146                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
147                         COMMAND rm -Rf ${TARGETDIR}/${BLENDER_VERSION}
148                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/
149                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/${BLENDER_VERSION}/
150                 )
151         
152                 IF(WITH_INTERNATIONAL)
153                         ADD_CUSTOM_COMMAND(
154                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
155                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/${BLENDER_VERSION}/
156                                 COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/${BLENDER_VERSION}/
157                         )
158                 ENDIF(WITH_INTERNATIONAL)
159         
160                 IF(WITH_PYTHON)
161                         ADD_CUSTOM_COMMAND(
162                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
163                                 COMMENT "copying blender scripts..."
164                                 COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/${BLENDER_VERSION}/
165                                 COMMAND find ${TARGETDIR} -name "*.py?" -prune -exec rm -rf {} "\;"
166                         )
167                         IF(WITH_PYTHON_INSTALL)
168                                 # Copy the systems python into the install directory
169                                 # Scons copy in tools/Blender.py
170                                 ADD_CUSTOM_COMMAND(
171                                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
172                                         COMMENT "copying a subset of the systems python..."
173
174                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python # PYTHONPATH and PYTHONHOME is set here
175                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python/lib/
176                                         COMMAND cp -R ${PYTHON_LIBPATH}/python${PYTHON_VERSION} ${TARGETDIR}/${BLENDER_VERSION}/python/lib/
177
178                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/distutils
179                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/lib2to3
180                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/idlelib
181                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/tkinter
182                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/config
183
184                                         COMMAND rm -rf ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/site-packages
185                                         COMMAND mkdir ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/site-packages  # python needs it.
186
187                                         COMMAND rm -f ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION}/lib-dynload/_tkinter.so
188                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "test" -prune -exec rm -rf {} "\;"
189                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "*.py?" -exec rm -rf {} "\;"
190                                         COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/python${PYTHON_VERSION} -name "*.so"-exec strip -s {} "\;"
191                                 )
192                         ENDIF(WITH_PYTHON_INSTALL)
193                 ENDIF(WITH_PYTHON)
194           
195                 ADD_CUSTOM_COMMAND(
196                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
197                         COMMAND find ${TARGETDIR} -name .svn -prune -exec rm -rf {} "\;"
198                 )
199         
200         
201                 # Above we bundle a portable distribution in ./bin
202                 # This is an optional "make install" which installs blender on the system.
203                 INSTALL(
204                         PROGRAMS ${TARGETDIR}/blender
205                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
206                 )
207
208                 IF(WITH_GAMEENGINE AND WITH_PLAYER)
209                         INSTALL(
210                                 PROGRAMS ${TARGETDIR}/blenderplayer
211                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
212                         )
213                 ENDIF(WITH_GAMEENGINE AND WITH_PLAYER)
214
215                 INSTALL(
216                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
217                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
218                 )
219                 INSTALL(
220                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/blender.svg
221                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps
222                 )
223                 INSTALL(
224                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
225                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
226                 )
227                 INSTALL(
228                         FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
229                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
230                 )
231                 INSTALL(
232                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/
233                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
234                         PATTERN ".svn" EXCLUDE
235                 )
236                 INSTALL(
237                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts/
238                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/scripts
239                         PATTERN ".svn" EXCLUDE
240                         PATTERN "*.pyc" EXCLUDE
241                 )
242                 INSTALL(
243                         DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/brushicons/
244                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/datafiles/brushicons
245                         PATTERN ".svn" EXCLUDE
246                 )
247                 IF(WITH_INTERNATIONAL)
248                         INSTALL(
249                                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/
250                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION}/datafiles/locale
251                                 PATTERN ".svn" EXCLUDE
252                         )
253                 ENDIF(WITH_INTERNATIONAL)
254                 
255                 # end "make install"
256         
257         ENDIF(UNIX AND NOT APPLE)
258
259         IF(APPLE)
260                 SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
261                 SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
262                 SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
263
264                 ADD_CUSTOM_COMMAND(
265                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
266                         COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
267                         COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
268                         COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
269                         COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
270                         COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
271                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
272                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
273                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
274                 )
275           
276                 IF(WITH_INTERNATIONAL)
277                         ADD_CUSTOM_COMMAND(
278                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
279                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
280                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
281                         )
282                 ENDIF(WITH_INTERNATIONAL)
283           
284                 IF(WITH_PYTHON)
285                         SET(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
286                         ADD_CUSTOM_COMMAND(
287                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
288                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/
289                                 COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
290                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
291                                 COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;"
292                         )
293                 ENDIF(WITH_PYTHON)        
294         
295                 ADD_CUSTOM_COMMAND(
296                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender       
297                         COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
298                         COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
299                                         COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;"
300                 )
301         ENDIF(APPLE)
302
303         IF(WIN32)
304                 # notice 'xcopy /Y /H' on .bfont.ttf, this is needed when building over samba
305                 ADD_CUSTOM_COMMAND(TARGET blender
306                         POST_BUILD
307                         MAIN_DEPENDENCY blender
308                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\"
309                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\"
310                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\"
311                         COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\"
312                         COMMAND xcopy /Y /H \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\"
313                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\scripts\\\"
314                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\plugins\\\"
315                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\\\"
316                 )
317         
318                 IF(CMAKE_CL_64)
319                         # gettext and png are statically linked on win64
320                         ADD_CUSTOM_COMMAND(TARGET blender
321                                 POST_BUILD
322                                 MAIN_DEPENDENCY blender
323                                 COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
324                         )
325                 ELSE(CMAKE_CL_64)
326                         ADD_CUSTOM_COMMAND(TARGET blender
327                                 POST_BUILD
328                                 MAIN_DEPENDENCY blender
329                                 COMMAND copy /Y \"${LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\"
330                                 COMMAND copy /Y \"${LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\"
331                                 COMMAND copy /Y \"${LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\"
332                         )
333                 ENDIF(CMAKE_CL_64)
334                 
335                 
336                 IF(MSVC)
337                         ADD_CUSTOM_COMMAND(TARGET blender
338                                 POST_BUILD
339                                 MAIN_DEPENDENCY blender
340                                 COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\"
341                         )
342                 ELSE(MSVC)
343                         ADD_CUSTOM_COMMAND(TARGET blender
344                                 POST_BUILD
345                                 MAIN_DEPENDENCY blender
346                                 COMMAND copy /Y \"${LIBDIR}\\pthreads\\lib\\pthreadGC2.dll\" \"${TARGETDIR}\\\"
347                         )
348                 ENDIF(MSVC)
349
350                 IF(WITH_PYTHON)
351                         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
352                                 ADD_CUSTOM_COMMAND(TARGET blender
353                                         POST_BUILD
354                                         MAIN_DEPENDENCY blender
355                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\"
356                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
357                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
358                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
359                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
360                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
361                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
362                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
363                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
364                                 )
365                         ELSE(NOT CMAKE_BUILD_TYPE)
366                                 IF(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
367                                         ADD_CUSTOM_COMMAND(TARGET blender
368                                                 POST_BUILD
369                                                 MAIN_DEPENDENCY blender
370                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
371                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
372                                         )
373                                 ELSE(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
374                                         ADD_CUSTOM_COMMAND(TARGET blender
375                                                 POST_BUILD
376                                                 MAIN_DEPENDENCY blender
377                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
378                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
379                                         )
380                                 ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
381                         ENDIF(NOT CMAKE_BUILD_TYPE)
382                 ENDIF(WITH_PYTHON)
383
384                 IF(WITH_INTERNATIONAL)
385                         IF(CMAKE_CL_64)
386                                 # iconv is statically linked on win64
387                                 ADD_CUSTOM_COMMAND(TARGET blender
388                                         POST_BUILD
389                                         MAIN_DEPENDENCY blender
390                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
391                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
392                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
393                                 )
394                         ELSE(CMAKE_CL_64)
395                                 ADD_CUSTOM_COMMAND(TARGET blender
396                                         POST_BUILD
397                                         MAIN_DEPENDENCY blender
398                                         COMMAND copy /Y \"${LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
399                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
400                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
401                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
402                                 )
403                         ENDIF(CMAKE_CL_64)
404                 ENDIF(WITH_INTERNATIONAL)
405
406                 IF(WITH_FFMPEG)
407                         ADD_CUSTOM_COMMAND(TARGET blender
408                                 POST_BUILD
409                                 MAIN_DEPENDENCY blender
410                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
411                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
412                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
413                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
414                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
415                         )
416                 ENDIF(WITH_FFMPEG)
417
418                 IF(WITH_SNDFILE)
419                         ADD_CUSTOM_COMMAND(TARGET blender
420                                 POST_BUILD
421                                 MAIN_DEPENDENCY blender
422                                 COMMAND copy /Y \"${LIBDIR}\\sndfile\\lib\\libsndfile-1.dll\" \"${TARGETDIR}\\\"
423                         )
424                 ENDIF(WITH_SNDFILE)
425
426                 IF(WITH_JACK)
427                         ADD_CUSTOM_COMMAND(TARGET blender
428                                 POST_BUILD
429                                 MAIN_DEPENDENCY blender
430                                 COMMAND copy /Y \"${LIBDIR}\\jack\\lib\\libjack.dll\" \"${TARGETDIR}\\\"
431                         )
432                 ENDIF(WITH_JACK)
433
434                 IF(WITH_OPENAL)
435                         ADD_CUSTOM_COMMAND(TARGET blender
436                                 POST_BUILD
437                                 MAIN_DEPENDENCY blender
438                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\OpenAL32.dll\" \"${TARGETDIR}\\\"
439                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\wrap_oal.dll\" \"${TARGETDIR}\\\"
440
441                         )
442                 ENDIF(WITH_OPENAL)
443
444                 IF(WITH_SDL)
445                         IF(NOT CMAKE_CL_64)
446                                 ADD_CUSTOM_COMMAND(TARGET blender
447                                         POST_BUILD
448                                         MAIN_DEPENDENCY blender
449                                         COMMAND copy /Y \"${LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
450                                 )
451                         ENDIF(NOT CMAKE_CL_64)
452                 ENDIF(WITH_SDL)
453
454         ENDIF(WIN32)
455 ENDIF(WITH_INSTALL)
456
457 ADD_DEPENDENCIES(blender makesdna)
458
459 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
460
461 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
462
463 IF(WITH_MOD_FLUID)
464         LIST(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
465 ENDIF(WITH_MOD_FLUID)
466
467
468 #IF(UNIX)
469         # Sort libraries
470         SET(BLENDER_SORTED_LIBS
471                 bf_windowmanager
472
473                 bf_editor_space_api
474                 bf_editor_space_action
475                 bf_editor_space_buttons
476                 bf_editor_space_console
477                 bf_editor_space_file
478                 bf_editor_space_graph
479                 bf_editor_space_image
480                 bf_editor_space_info
481                 bf_editor_space_logic
482                 bf_editor_space_nla
483                 bf_editor_space_node
484                 bf_editor_space_outliner
485                 bf_editor_space_script
486                 bf_editor_space_sequencer
487                 bf_editor_space_sound
488                 bf_editor_space_time
489                 bf_editor_space_userpref
490                 bf_editor_space_view3d
491
492                 bf_editor_text
493                 bf_editor_transform
494                 bf_editor_util
495                 bf_editor_uvedit
496                 bf_editor_curve
497                 bf_editor_armature
498                 bf_editor_gpencil
499                 bf_editor_interface
500                 bf_editor_mesh
501                 bf_editor_metaball
502                 bf_editor_object
503                 bf_editor_physics
504                 bf_editor_render
505                 bf_editor_screen
506                 bf_editor_sculpt_paint
507                 bf_editor_sound
508                 bf_editor_animation
509                 bf_editor_datafiles
510
511                 bf_render 
512                 bf_intern_opennl 
513                 bf_python 
514                 bf_python_ext 
515                 bf_ikplugin
516                 bf_modifiers
517                 bf_blenkernel
518                 bf_nodes
519                 bf_gpu
520                 bf_blenloader
521                 bf_blenlib
522                 bf_intern_ghost
523                 bf_intern_string
524                 bf_blenpluginapi 
525                 bf_imbuf 
526                 bf_avi 
527                 bf_imbuf_cineon 
528                 bf_imbuf_openexr 
529                 bf_imbuf_dds
530                 bf_readblenfile
531                 bf_collada
532                 bf_intern_bsp 
533                 bf_intern_bop 
534                 bf_gen_system 
535                 bf_intern_decimate 
536                 bf_intern_elbeem 
537                 bf_intern_ik 
538                 bf_intern_memutil 
539                 bf_intern_guardedalloc 
540                 bf_intern_ctr 
541                 ge_blen_routines 
542                 ge_converter 
543                 ge_phys_dummy
544                 ge_phys_bullet 
545                 bf_intern_smoke
546                 extern_minilzo
547                 extern_lzma
548                 ge_logic_ketsji 
549                 ge_phys_common
550                 ge_logic 
551                 ge_rasterizer 
552                 ge_oglrasterizer 
553                 ge_logic_expressions 
554                 ge_scenegraph 
555                 ge_logic_network 
556                 bf_gen_system
557                 bf_python # duplicate for BPY_eval_driver
558                 ge_logic_ngnetwork 
559                 extern_bullet 
560                 ge_logic_loopbacknetwork 
561                 bf_intern_moto 
562                 extern_glew
563                 extern_openjpeg
564                 ge_videotex
565                 bf_rna
566                 bf_dna
567                 bf_blenfont
568                 bf_intern_audaspace
569         )
570
571         IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
572                 LIST(APPEND BLENDER_SORTED_LIBS extern_binreloc)
573         ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
574
575         IF(WITH_CXX_GUARDEDALLOC)
576                 LIST(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
577         ENDIF(WITH_CXX_GUARDEDALLOC)
578
579         IF(WITH_IK_ITASC)
580                 LIST(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
581         ENDIF(WITH_IK_ITASC)
582
583         IF(WITH_QUICKTIME)
584                 LIST(APPEND BLENDER_SORTED_LIBS bf_quicktime)
585         ENDIF(WITH_QUICKTIME)
586
587
588         FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
589                 SET(REMLIB ${SORTLIB})
590                 FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
591                         IF(${SEARCHLIB} STREQUAL ${SORTLIB})
592                                 SET(REMLIB "")
593                         ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
594                 ENDFOREACH(SEARCHLIB)
595                 IF(REMLIB)
596                         MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
597                         LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
598                 ENDIF(REMLIB)
599         ENDFOREACH(SORTLIB)
600         TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
601 #ELSE(UNIX)
602 #       TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
603 #ENDIF(UNIX)
604
605 SETUP_LIBLINKS(blender)