- check IF WIN32 AND NOT UNIX (for cygwin)
[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)\" == \"Debug\" copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
307                                         COMMAND if \"$(ConfigurationName)\" == \"Debug\" xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
308                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
309                                         COMMAND if \"$(ConfigurationName)\" == \"RelWithDebInfo\" xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
310                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
311                                         COMMAND if \"$(ConfigurationName)\" == \"Release\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
312                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
313                                         COMMAND if \"$(ConfigurationName)\" == \"MinSizeRel\" xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
314                                 )
315                         ELSE(NOT CMAKE_BUILD_TYPE)
316                                 IF(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
317                                         ADD_CUSTOM_COMMAND(TARGET blender
318                                                 POST_BUILD
319                                                 MAIN_DEPENDENCY blender
320                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31_d.dll\" \"${TARGETDIR}\\\"
321                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31_d\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
322                                         )
323                                 ELSE(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
324                                         ADD_CUSTOM_COMMAND(TARGET blender
325                                                 POST_BUILD
326                                                 MAIN_DEPENDENCY blender
327                                                 COMMAND copy /Y \"${LIBDIR}\\python\\lib\\python31.dll\" \"${TARGETDIR}\\\"
328                                                 COMMAND xcopy /E /Y \"${LIBDIR}\\release\\python31\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\python\\lib\\\"
329                                         )
330                                 ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
331                         ENDIF(NOT CMAKE_BUILD_TYPE)
332                 ENDIF(WITH_PYTHON)
333
334                 IF(WITH_INTERNATIONAL)
335                         IF(CMAKE_CL_64)
336                                 # iconv is statically linked on win64
337                                 ADD_CUSTOM_COMMAND(TARGET blender
338                                         POST_BUILD
339                                         MAIN_DEPENDENCY blender
340                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
341                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
342                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
343                                 )
344                         ELSE(CMAKE_CL_64)
345                                 ADD_CUSTOM_COMMAND(TARGET blender
346                                         POST_BUILD
347                                         MAIN_DEPENDENCY blender
348                                         COMMAND copy /Y \"${LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\"
349                                         COMMAND if not exist \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\" mkdir \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\"
350                                         COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\\" 
351                                         COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\${BLENDER_VERSION}\\config\\locale\\\"
352                                 )
353                         ENDIF(CMAKE_CL_64)
354                 ENDIF(WITH_INTERNATIONAL)
355
356                 IF(WITH_FFMPEG)
357                         ADD_CUSTOM_COMMAND(TARGET blender
358                                 POST_BUILD
359                                 MAIN_DEPENDENCY blender
360                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\"
361                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\"
362                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\"
363                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\"
364                                 COMMAND copy /Y \"${LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\"
365                         )
366                 ENDIF(WITH_FFMPEG)
367
368                 IF(WITH_SNDFILE)
369                         ADD_CUSTOM_COMMAND(TARGET blender
370                                 POST_BUILD
371                                 MAIN_DEPENDENCY blender
372                                 COMMAND copy /Y \"${LIBDIR}\\sndfile\\lib\\libsndfile-1.dll\" \"${TARGETDIR}\\\"
373                         )
374                 ENDIF(WITH_SNDFILE)
375
376                 IF(WITH_JACK)
377                         ADD_CUSTOM_COMMAND(TARGET blender
378                                 POST_BUILD
379                                 MAIN_DEPENDENCY blender
380                                 COMMAND copy /Y \"${LIBDIR}\\jack\\lib\\libjack.dll\" \"${TARGETDIR}\\\"
381                         )
382                 ENDIF(WITH_JACK)
383
384                 IF(WITH_OPENAL)
385                         ADD_CUSTOM_COMMAND(TARGET blender
386                                 POST_BUILD
387                                 MAIN_DEPENDENCY blender
388                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\OpenAL32.dll\" \"${TARGETDIR}\\\"
389                                 COMMAND copy /Y \"${LIBDIR}\\openal\\lib\\wrap_oal.dll\" \"${TARGETDIR}\\\"
390
391                         )
392                 ENDIF(WITH_OPENAL)
393
394                 IF(WITH_SDL)
395                         IF(NOT CMAKE_CL_64)
396                                 ADD_CUSTOM_COMMAND(TARGET blender
397                                         POST_BUILD
398                                         MAIN_DEPENDENCY blender
399                                         COMMAND copy /Y \"${LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\"
400                                 )
401                         ENDIF(NOT CMAKE_CL_64)
402                 ENDIF(WITH_SDL)
403
404         ELSEIF(APPLE)
405                 SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
406                 SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
407                 SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist)
408
409                 ADD_CUSTOM_COMMAND(
410                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender
411                         COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/
412                         COMMAND cp -Rf ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/
413                         COMMAND cp -Rf ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/
414                         COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO}
415                         COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
416                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}
417                         COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
418                         COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
419                 )
420           
421                 IF(WITH_INTERNATIONAL)
422                         ADD_CUSTOM_COMMAND(
423                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
424                                 COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
425                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/datafiles/
426                         )
427                 ENDIF(WITH_INTERNATIONAL)
428           
429                 IF(WITH_PYTHON)
430                         SET(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
431                         ADD_CUSTOM_COMMAND(
432                                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
433                                 COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/
434                                 COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
435                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION}/python/
436                                 COMMAND find ${TARGETDIR}/blender.app -name "*.py?" -prune -exec rm -rf {} "\;"
437                         )
438                 ENDIF(WITH_PYTHON)        
439         
440                 ADD_CUSTOM_COMMAND(
441                         TARGET blender POST_BUILD MAIN_DEPENDENCY blender       
442                         COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;"
443                         COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;"
444                                         COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;"
445                 )
446         ENDIF(UNIX AND NOT APPLE)
447
448 ENDIF(WITH_INSTALL)
449
450 ADD_DEPENDENCIES(blender makesdna)
451
452 FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
453
454 SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_render)
455
456 IF(WITH_MOD_FLUID)
457         LIST(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
458 ENDIF(WITH_MOD_FLUID)
459
460
461 #IF(UNIX)
462         # Sort libraries
463         SET(BLENDER_SORTED_LIBS
464                 bf_windowmanager
465
466                 bf_editor_space_api
467                 bf_editor_space_action
468                 bf_editor_space_buttons
469                 bf_editor_space_console
470                 bf_editor_space_file
471                 bf_editor_space_graph
472                 bf_editor_space_image
473                 bf_editor_space_info
474                 bf_editor_space_logic
475                 bf_editor_space_nla
476                 bf_editor_space_node
477                 bf_editor_space_outliner
478                 bf_editor_space_script
479                 bf_editor_space_sequencer
480                 bf_editor_space_sound
481                 bf_editor_space_time
482                 bf_editor_space_userpref
483                 bf_editor_space_view3d
484
485                 bf_editor_text
486                 bf_editor_transform
487                 bf_editor_util
488                 bf_editor_uvedit
489                 bf_editor_curve
490                 bf_editor_armature
491                 bf_editor_gpencil
492                 bf_editor_interface
493                 bf_editor_mesh
494                 bf_editor_metaball
495                 bf_editor_object
496                 bf_editor_physics
497                 bf_editor_render
498                 bf_editor_screen
499                 bf_editor_sculpt_paint
500                 bf_editor_sound
501                 bf_editor_animation
502                 bf_editor_datafiles
503
504                 bf_render 
505                 bf_intern_opennl 
506                 bf_python 
507                 bf_python_ext 
508                 bf_ikplugin
509                 bf_modifiers
510                 bf_blenkernel
511                 bf_nodes
512                 bf_gpu
513                 bf_blenloader
514                 bf_blenlib
515                 bf_intern_ghost
516                 bf_intern_string
517                 bf_blenpluginapi 
518                 bf_imbuf 
519                 bf_avi 
520                 bf_imbuf_cineon 
521                 bf_imbuf_openexr 
522                 bf_imbuf_dds
523                 bf_readblenfile
524                 bf_collada
525                 bf_intern_bsp 
526                 bf_intern_bop 
527                 bf_gen_system 
528                 bf_intern_decimate 
529                 bf_intern_elbeem 
530                 bf_intern_ik 
531                 bf_intern_memutil 
532                 bf_intern_guardedalloc 
533                 bf_intern_ctr 
534                 ge_blen_routines 
535                 ge_converter 
536                 ge_phys_dummy
537                 ge_phys_bullet 
538                 bf_intern_smoke
539                 extern_minilzo
540                 extern_lzma
541                 ge_logic_ketsji 
542                 ge_phys_common
543                 ge_logic 
544                 ge_rasterizer 
545                 ge_oglrasterizer 
546                 ge_logic_expressions 
547                 ge_scenegraph 
548                 ge_logic_network 
549                 bf_gen_system
550                 bf_python # duplicate for BPY_eval_driver
551                 ge_logic_ngnetwork 
552                 extern_bullet 
553                 ge_logic_loopbacknetwork 
554                 bf_intern_moto 
555                 extern_glew
556                 extern_openjpeg
557                 ge_videotex
558                 bf_rna
559                 bf_dna
560                 bf_blenfont
561                 bf_intern_audaspace
562         )
563
564         IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
565                 LIST(APPEND BLENDER_SORTED_LIBS extern_binreloc)
566         ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
567
568         IF(WITH_CXX_GUARDEDALLOC)
569                 LIST(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
570         ENDIF(WITH_CXX_GUARDEDALLOC)
571
572         IF(WITH_IK_ITASC)
573                 LIST(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
574         ENDIF(WITH_IK_ITASC)
575
576         IF(WITH_QUICKTIME)
577                 LIST(APPEND BLENDER_SORTED_LIBS bf_quicktime)
578         ENDIF(WITH_QUICKTIME)
579
580
581         FOREACH(SORTLIB ${BLENDER_SORTED_LIBS})
582                 SET(REMLIB ${SORTLIB})
583                 FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS})
584                         IF(${SEARCHLIB} STREQUAL ${SORTLIB})
585                                 SET(REMLIB "")
586                         ENDIF(${SEARCHLIB} STREQUAL ${SORTLIB})
587                 ENDFOREACH(SEARCHLIB)
588                 IF(REMLIB)
589                         MESSAGE(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
590                         LIST(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
591                 ENDIF(REMLIB)
592         ENDFOREACH(SORTLIB)
593         TARGET_LINK_LIBRARIES(blender ${BLENDER_SORTED_LIBS})
594 #ELSE(UNIX)
595 #       TARGET_LINK_LIBRARIES(blender ${BLENDER_LINK_LIBS})
596 #ENDIF(UNIX)
597
598 SETUP_LIBLINKS(blender)