whitespace commit
[blender-staging.git] / 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 #-----------------------------------------------------------------------------
28 # We don't allow in-source builds. This causes no end of troubles because 
29 # all out-of-source builds will use the CMakeCache.txt file there and even 
30 # build the libs and objects in it. It will also conflict with the current 
31 # Makefile system for Blender
32
33 IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
34 MESSAGE(FATAL_ERROR "CMake generation for blender is not allowed within the source directory! 
35 Remove the CMakeCache.txt file and try again from another folder, e.g.: 
36
37    rm CMakeCache.txt 
38    cd ..
39    mkdir cmake-make 
40    cd cmake-make
41    cmake -G \"Unix Makefiles\" ../blender
42 ")
43 ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
44
45 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
46 PROJECT(Blender)
47
48 #-----------------------------------------------------------------------------
49 # Redirect output files
50
51 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
52 SET(LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
53
54 #-----------------------------------------------------------------------------
55 # Set default config options
56 OPTION(WITH_PLAYER              "Build Player"                                          OFF)
57 OPTION(WITH_GAMEENGINE          "Enable Game Engine"                                    OFF)
58 OPTION(WITH_BULLET              "Enable Bullet (Physics Engine)"                        ON)
59 OPTION(WITH_INTERNATIONAL       "Enable I18N   (International fonts and text)"          ON)
60 OPTION(WITH_VERSE               "Enable Verse  (http://verse.blender.org)"              OFF)
61 OPTION(WITH_ELBEEM              "Enable Elbeem (Fluid Simulation)"                      ON)
62 OPTION(WITH_QUICKTIME           "Enable Quicktime Support"                              OFF)
63 OPTION(WITH_OPENEXR             "Enable OpenEXR Support (http://www.openexr.com)"       OFF)
64 OPTION(WITH_FFMPEG              "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)"   OFF)
65 OPTION(WITH_OPENAL              "Enable OpenAL Support (http://www.openal.org)" ON)
66 OPTION(YESIAMSTUPID             "Enable execution on 64-bit platforms"                                  OFF)
67
68 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
69   MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
70 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
71
72 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
73 # On Unix: 
74 #   cmake -D PYTHON_LIB=/usr/local/lib/python2.3/config/libpython2.3.so -D PYTHON_INC=/usr/local/include/python2.3 -D PYTHON_BINARY=/usr/local/bin/python2.3 -G "Unix Makefiles" ../blender
75 # On Macs: 
76 #   cmake -D PYTHON_INC=/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config -D PYTHON_BINARY=/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 -G Xcode ../blender
77 #
78 # When changing any of this remember to update the notes in doc/blender-cmake.txt
79
80 #-----------------------------------------------------------------------------
81 # Load some macros.
82 INCLUDE(CMake/macros.cmake)
83
84 #-----------------------------------------------------------------------------
85 #Platform specifics
86
87 IF(UNIX)
88   INCLUDE(${CMAKE_ROOT}/Modules/FindOpenAL.cmake)
89   IF(OPENAL_FOUND)
90     SET(WITH_OPENAL ON)
91     SET(OPENAL_LIB ${OPENAL_LIBRARY})
92     SET(OPENAL_INC ${OPENAL_INCLUDE_DIR})
93   ELSE(OPENAL_FOUND)
94     SET(WITH_OPENAL OFF)
95   ENDIF(OPENAL_FOUND)
96
97   FIND_LIBRARY(ALUT_LIBRARY
98     NAMES alut
99     PATHS
100     /usr/local/lib
101     /usr/lib
102     /sw/lib
103     /opt/local/lib
104     /opt/csw/lib
105     /opt/lib
106   )
107   IF(ALUT_LIBRARY)
108     SET(OPENAL_LIB ${OPENAL_LIB} ${ALUT_LIBRARY})
109   ENDIF(ALUT_LIBRARY)
110
111   FIND_LIBRARY(INTL_LIBRARY
112     NAMES intl
113     PATHS
114     /usr/local/lib
115     /usr/lib
116     /sw/lib
117     /opt/local/lib
118     /opt/csw/lib
119     /opt/lib
120   )
121   FIND_LIBRARY(ICONV_LIBRARY
122     NAMES iconv
123     PATHS
124     /usr/local/lib
125     /usr/lib
126     /sw/lib
127     /opt/local/lib
128     /opt/csw/lib
129     /opt/lib
130   )
131   IF(INTL_LIBRARY AND ICONV_LIBRARY)
132     SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
133   ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
134   
135   FIND_PATH(FREETYPE_INC
136     freetype
137     PATHS
138     /usr/local/include/freetype2
139     /usr/include/freetype2
140     /sw/include/freetype2
141     /opt/local/include/freetype2
142     /opt/csw/include/freetype2
143     /opt/include/freetype2
144     NO_DEFAULT_PATH
145   )
146   SET(FREETYPE_LIB freetype)
147
148   INCLUDE(${CMAKE_ROOT}/Modules/FindPythonLibs.cmake)
149   SET(PYTHON_INC "${PYTHON_INCLUDE_PATH}" CACHE STRING "")
150   SET(PYTHON_LIB "${PYTHON_LIBRARIES}" CACHE STRING "")
151   INCLUDE(${CMAKE_ROOT}/Modules/FindPythonInterp.cmake)
152   SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
153   SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
154
155   INCLUDE(${CMAKE_ROOT}/Modules/FindSDL.cmake)
156   SET(SDL_INC ${SDL_INCLUDE_DIR})
157   SET(SDL_LIB ${SDL_LIBRARY})
158
159   FIND_PATH(OPENEXR_INC
160     ImfXdr.h
161     PATHS
162     /usr/local/include/OpenEXR
163     /usr/include/OpenEXR
164     /sw/include/OpenEXR
165     /opt/local/include/OpenEXR
166     /opt/csw/include/OpenEXR
167     /opt/include/OpenEXR
168   )
169   SET(OPENEXR_LIB Half IlmImf Iex Imath)
170
171   SET(FFMPEG /usr)
172   SET(FFMPEG_INC ${FFMPEG}/include)
173   SET(FFMPEG_LIB avformat avcodec avutil)
174   SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
175
176   SET(JPEG_LIB jpeg)
177
178   SET(PNG_LIB png)
179
180   SET(ZLIB_LIB z)
181
182   SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++")
183
184   SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -DXP_UNIX -Wno-char-subscripts")
185
186   SET(PLATFORM_LINKFLAGS "-pthread")
187
188   INCLUDE_DIRECTORIES(/usr/include /usr/local/include)
189 ENDIF(UNIX)
190
191 IF(WIN32)
192   INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
193
194   SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
195
196   SET(PYTHON ${LIBDIR}/python)
197   SET(PYTHON_VERSION 2.5)
198   SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
199   SET(PYTHON_BINARY python)
200   SET(PYTHON_LIB python25)
201   SET(PYTHON_LIBPATH ${PYTHON}/lib)
202
203   #SET(WITH_OPENAL ON)
204   SET(OPENAL ${LIBDIR}/openal)
205   SET(OPENAL_INC ${OPENAL}/include ${OPENAL}/include/AL)
206   SET(OPENAL_LIB openal_static)
207   SET(OPENAL_LIBPATH ${OPENAL}/lib)
208
209   SET(PNG_LIB libpng_st)
210   SET(JPEG_LIB libjpeg)
211
212   SET(ZLIB ${LIBDIR}/zlib)
213   SET(ZLIB_INC ${ZLIB}/include)
214   SET(ZLIB_LIB libz)
215   SET(ZLIB_LIBPATH ${ZLIB}/lib)
216   
217   SET(PTHREADS ${LIBDIR}/pthreads)
218   SET(PTHREADS_INC ${PTHREADS}/include)
219   SET(PTHREADS_LIB pthreadVC2)
220   SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
221   
222   SET(ICONV ${LIBDIR}/iconv)
223   SET(ICONV_INC ${ICONV}/include)
224   SET(ICONV_LIB iconv)
225   SET(ICONV_LIBPATH ${ICONV}/lib)
226   
227   SET(GETTEXT ${LIBDIR}/gettext)
228   SET(GETTEXT_INC ${GETTEXT}/include)
229   SET(GETTEXT_LIB gnu_gettext)
230   SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
231
232   SET(FREETYPE ${LIBDIR}/freetype)
233   SET(FREETYPE_INC ${FREETYPE}/include ${FREETYPE}/include/freetype2)
234   SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
235   SET(FREETYPE_LIB freetype2ST)
236   
237   SET(OPENEXR ${LIBDIR}/openexr)
238   SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
239   SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
240   IF (MSVC80)
241   SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
242   ELSE (MSVC80)
243   SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
244   ENDIF(MSVC80)
245   
246   SET(QUICKTIME ${LIBDIR}/QTDevWin)
247   SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
248   SET(QUICKTIME_LIB qtmlClient)
249   SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
250
251   SET(FFMPEG ${LIBDIR}/ffmpeg)
252   SET(FFMPEG_INC ${FFMPEG}/include)
253   SET(FFMPEG_LIB avcodec-51 avformat-51 avutil-49)
254   SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
255
256   SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
257   IF(WITH_OPENAL)
258     SET(LLIBS ${LLIBS} dxguid)
259   ENDIF(WITH_OPENAL)
260
261   SET(CMAKE_CXX_FLAGS_DEBUG "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
262   SET(CMAKE_CXX_FLAGS_RELEASE "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
263   SET(CMAKE_CXX_FLAGS_MINSIZEREL "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
264   SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
265   SET(CMAKE_C_FLAGS_DEBUG "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
266   SET(CMAKE_C_FLAGS_RELEASE "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
267   SET(CMAKE_C_FLAGS_MINSIZEREL "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
268   SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
269
270   SET(SDL ${LIBDIR}/sdl)
271   SET(SDL_INC ${SDL}/include)
272   SET(SDL_LIB SDL)
273   SET(SDL_LIBPATH ${SDL}/lib)
274
275   SET(PNG "${LIBDIR}/png")
276   SET(PNG_INC "${PNG}/include")
277   SET(PNG_LIBPATH ${PNG}/lib)
278
279   SET(JPEG "${LIBDIR}/jpeg")
280   SET(JPEG_INC "${JPEG}/include")
281   SET(JPEG_LIBPATH ${JPEG}/lib)
282
283   SET(TIFF ${LIBDIR}/tiff)
284   SET(TIFF_INC ${TIFF}/include)
285   
286   SET(WINTAB_INC ${LIBDIR}/wintab/include) 
287
288   SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib")
289   SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
290 ENDIF(WIN32)
291
292 IF(APPLE)
293   IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
294     SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
295   ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
296     SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-6.1-powerpc)
297   ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
298
299   INCLUDE(${CMAKE_ROOT}/Modules/FindOpenAL.cmake)
300   IF(OPENAL_FOUND)
301     SET(WITH_OPENAL ON)
302     SET(OPENAL_LIB ${OPENAL_LIBRARY})
303     SET(OPENAL_INC ${OPENAL_INCLUDE_DIR})
304   ELSE(OPENAL_FOUND)
305     SET(WITH_OPENAL OFF)
306   ENDIF(OPENAL_FOUND)
307
308   SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
309   SET(PYTHON_VERSION 2.3)
310   SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}" CACHE STRING "")
311   SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION} CACHE STRING "")
312   SET(PYTHON_LIB "")
313   SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config CACHE STRING "")
314   SET(PYTHON_LINKFLAGS "-u __dummy -u _PyMac_Error -framework System -framework Python")
315
316   SET(GETTEXT ${LIBDIR}/gettext)
317   SET(GETTEXT_INC "${GETTEXT}/include")
318   SET(GETTEXT_LIB intl iconv)
319   SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
320
321   SET(PNG_LIB png)
322   SET(JPEG_LIB jpeg)
323
324   SET(ZLIB /usr)
325   SET(ZLIB_INC "${ZLIB}/include")
326   SET(ZLIB_LIB z)
327
328   SET(FREETYPE ${LIBDIR}/freetype)
329   SET(FREETYPE_INC ${FREETYPE}/include ${FREETYPE}/include/freetype2)
330   SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
331   SET(FREETYPE_LIB freetype)
332
333   SET(OPENEXR ${LIBDIR}/openexr)
334   SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
335   IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
336     SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
337   ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
338     SET(OPENEXR_LIB Iex Half IlmImf Imath)
339   ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
340   SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
341
342   SET(LLIBS stdc++ SystemStubs)
343
344   SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
345   SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
346
347   SET(SDL ${LIBDIR}/sdl)
348   SET(SDL_INC ${SDL}/include)
349   SET(SDL_LIB SDL)
350   SET(SDL_LIBPATH ${SDL}/lib)
351
352   SET(PNG "${LIBDIR}/png")
353   SET(PNG_INC "${PNG}/include")
354   SET(PNG_LIBPATH ${PNG}/lib)
355
356   SET(JPEG "${LIBDIR}/jpeg")
357   SET(JPEG_INC "${JPEG}/include")
358   SET(JPEG_LIBPATH ${JPEG}/lib)
359
360   SET(TIFF ${LIBDIR}/tiff)
361   SET(TIFF_INC ${TIFF}/include)
362
363   SET(EXETYPE MACOSX_BUNDLE)
364 ENDIF(APPLE)
365
366 #-----------------------------------------------------------------------------
367 # Common.
368 SET(VERSE_INC ${CMAKE_SOURCE_DIR}/extern/verse/dist)
369
370 SET(FTGL ${CMAKE_SOURCE_DIR}/extern/bFTGL)
371 SET(FTGL_INC ${FTGL}/include)
372 SET(FTGL_LIB extern_ftgl)
373
374
375 #-----------------------------------------------------------------------------
376 # Configure OpenGL.
377 INCLUDE(${CMAKE_ROOT}/Modules/FindOpenGL.cmake)
378 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
379 #-----------------------------------------------------------------------------
380 # Extra compile flags
381 IF(WITH_GAMEENGINE)
382   SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DGAMEBLENDER ")
383 ENDIF(WITH_GAMEENGINE)
384 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ")
385 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ")
386
387 #-----------------------------------------------------------------------------
388 # Libraries
389 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
390 SUBDIRS(
391   intern
392   extern
393   source
394 )
395
396
397 #-----------------------------------------------------------------------------
398 # Blender Application
399 SUBDIRS(source/creator)
400
401 #-----------------------------------------------------------------------------
402 # Blender Player
403 IF(WITH_PLAYER)
404   SUBDIRS(blenderplayer)
405 ENDIF(WITH_PLAYER)