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