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