Step 1 of Bullet 2.x upgrade:
[blender.git] / CMakeLists.txt
1 # $Id$
2 # ***** BEGIN GPL/BL DUAL 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. The Blender
8 # Foundation also sells licenses for use in proprietary software under
9 # the Blender License.  See http://www.blender.org/BL/ for information
10 # about this.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software Foundation,
19 # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 #
21 # The Original Code is Copyright (C) 2006, Blender Foundation
22 # All rights reserved.
23 #
24 # The Original Code is: all of this file.
25 #
26 # Contributor(s): Jacques Beaurain.
27 #
28 # ***** END GPL/BL DUAL LICENSE BLOCK *****
29
30 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
31 PROJECT(Blender)
32
33 #-----------------------------------------------------------------------------
34 # Redirect output files
35
36 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
37 SET(LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
38
39 #-----------------------------------------------------------------------------
40 # Set default config options
41 OPTION(WITH_PLAYER              "Build Player"                                          OFF)
42 OPTION(WITH_GAMEENGINE          "Enable Game Engine"                                    OFF)
43 OPTION(WITH_BULLET              "Enable Bullet (Physics Engine)"                        OFF)
44 OPTION(WITH_INTERNATIONAL       "Enable I18N   (International fonts and text)"          ON)
45 OPTION(WITH_VERSE               "Enable Verse  (http://verse.blender.org)"              OFF)
46 OPTION(WITH_ELBEEM              "Enable Elbeem (Fluid Simulation)"                      ON)
47 OPTION(WITH_QUICKTIME           "Enable Quicktime Support"                              OFF)
48 OPTION(WITH_OPENEXR             "Enable OpenEXR Support (http://www.openexr.com)"       OFF)
49 OPTION(WITH_FFMPEG              "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)"   OFF)
50
51 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
52   MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
53 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
54
55 #-----------------------------------------------------------------------------
56 # Load some macros.
57 INCLUDE(CMake/macros.cmake)
58
59 #-----------------------------------------------------------------------------
60 #Platform specifics
61
62 IF(UNIX)
63   INCLUDE(${CMAKE_ROOT}/Modules/FindOpenAL.cmake)
64   IF(OPENAL_FOUND)
65     SET(WITH_OPENAL ON)
66     SET(OPENAL_LIB ${OPENAL_LIBRARY})
67     SET(OPENAL_INC ${OPENAL_INCLUDE_DIR})
68   ELSE(OPENAL_FOUND)
69     SET(WITH_OPENAL OFF)
70   ENDIF(OPENAL_FOUND)
71
72   FIND_LIBRARY(ALUT_LIBRARY
73     NAMES alut
74     PATHS
75     /usr/local/lib
76     /usr/lib
77     /sw/lib
78     /opt/local/lib
79     /opt/csw/lib
80     /opt/lib
81   )
82   IF(ALUT_LIBRARY)
83     SET(OPENAL_LIB ${OPENAL_LIB} ${ALUT_LIBRARY})
84   ENDIF(ALUT_LIBRARY)
85
86   FIND_LIBRARY(INTL_LIBRARY
87     NAMES intl
88     PATHS
89     /usr/local/lib
90     /usr/lib
91     /sw/lib
92     /opt/local/lib
93     /opt/csw/lib
94     /opt/lib
95   )
96   FIND_LIBRARY(ICONV_LIBRARY
97     NAMES iconv
98     PATHS
99     /usr/local/lib
100     /usr/lib
101     /sw/lib
102     /opt/local/lib
103     /opt/csw/lib
104     /opt/lib
105   )
106   IF(INTL_LIBRARY AND ICONV_LIBRARY)
107     SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
108   ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
109   
110   FIND_PATH(FREETYPE_INC
111     freetype
112     PATHS
113     /usr/local/include/freetype2
114     /usr/include/freetype2
115     /sw/include/freetype2
116     /opt/local/include/freetype2
117     /opt/csw/include/freetype2
118     /opt/include/freetype2
119   )
120   SET(FREETYPE_LIB freetype)
121
122   INCLUDE(${CMAKE_ROOT}/Modules/FindPythonLibs.cmake)
123
124 # For FreeBSD (and possibly others) allow the commandline to override this to force Pyhon 2.3
125 # for instance. e.g:
126 # cmake -D PYTHON_LIB=/usr/local/lib/python2.3/config/libpython2.3.so -D PYTHON_INC=/usr/local/include/python2.3 -G "Unix Makefiles" ../blender
127
128   SET(PYTHON_INC "${PYTHON_INCLUDE_PATH}" CACHE STRING "")
129   SET(PYTHON_LIB "${PYTHON_LIBRARIES}" CACHE STRING "")
130
131   INCLUDE(${CMAKE_ROOT}/Modules/FindPythonInterp.cmake)
132   SET(PYTHON_BINARY ${PYTHON_EXECUTABLE})
133   SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
134
135   INCLUDE(${CMAKE_ROOT}/Modules/FindSDL.cmake)
136   SET(SDL_INC ${SDL_INCLUDE_DIR})
137   SET(SDL_LIB ${SDL_LIBRARY})
138
139   FIND_PATH(OPENEXR_INC
140     ImfXdr.h
141     PATHS
142     /usr/local/include/OpenEXR
143     /usr/include/OpenEXR
144     /sw/include/OpenEXR
145     /opt/local/include/OpenEXR
146     /opt/csw/include/OpenEXR
147     /opt/include/OpenEXR
148   )
149   SET(OPENEXR_LIB Half IlmImf Iex Imath)
150
151   SET(FFMPEG /usr)
152   SET(FFMPEG_INC ${FFMPEG}/include)
153   SET(FFMPEG_LIB avformat avcodec avutil)
154   SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
155
156   SET(JPEG_LIB jpeg)
157
158   SET(PNG_LIB png)
159
160   SET(ZLIB_LIB z)
161
162   SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++")
163
164   SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -DXP_UNIX -Wno-char-subscripts")
165
166   SET(PLATFORM_LINKFLAGS "-pthread")
167
168   INCLUDE_DIRECTORIES(/usr/include /usr/local/include)
169 ENDIF(UNIX)
170
171 IF(WIN32)
172   INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
173
174   SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
175
176   SET(PYTHON ${LIBDIR}/python)
177   SET(PYTHON_VERSION 2.4)
178   SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
179   SET(PYTHON_BINARY python)
180   SET(PYTHON_LIB python24)
181   SET(PYTHON_LIBPATH ${PYTHON}/lib)
182
183   SET(WITH_OPENAL ON)
184   SET(OPENAL ${LIBDIR}/openal)
185   SET(OPENAL_INC ${OPENAL}/include ${OPENAL}/include/AL)
186   SET(OPENAL_LIB openal_static)
187   SET(OPENAL_LIBPATH ${OPENAL}/lib)
188
189   SET(PNG_LIB libpng_st)
190   SET(JPEG_LIB libjpeg)
191
192   SET(ZLIB ${LIBDIR}/zlib)
193   SET(ZLIB_INC ${ZLIB}/include)
194   SET(ZLIB_LIB libz)
195   SET(ZLIB_LIBPATH ${ZLIB}/lib)
196   
197   SET(PTHREADS ${LIBDIR}/pthreads)
198   SET(PTHREADS_INC ${PTHREADS}/include)
199   SET(PTHREADS_LIB pthreadVC2)
200   SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
201   
202   SET(ICONV ${LIBDIR}/iconv)
203   SET(ICONV_INC ${ICONV}/include)
204   SET(ICONV_LIB iconv)
205   SET(ICONV_LIBPATH ${ICONV}/lib)
206   
207   SET(GETTEXT ${LIBDIR}/gettext)
208   SET(GETTEXT_INC ${GETTEXT}/include)
209   SET(GETTEXT_LIB gnu_gettext)
210   SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
211
212   SET(FREETYPE ${LIBDIR}/freetype)
213   SET(FREETYPE_INC ${FREETYPE}/include ${FREETYPE}/include/freetype2)
214   SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
215   SET(FREETYPE_LIB freetype2ST)
216   
217   SET(OPENEXR ${LIBDIR}/openexr)
218   SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
219   SET(OPENEXR_LIB Iex Half IlmImf Imath)
220   SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
221   
222   SET(QUICKTIME ${LIBDIR}/QTDevWin)
223   SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
224   SET(QUICKTIME_LIB qtmlClient)
225   SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
226
227   SET(FFMPEG ${LIBDIR}/ffmpeg)
228   SET(FFMPEG_INC ${FFMPEG}/include)
229   SET(FFMPEG_LIB avcodec-51 avformat-51 avutil-49)
230   SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
231
232   SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid odbc32 odbccp32 ws2_32 vfw32 winmm dxguid)
233
234   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)
235   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)
236   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)
237   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)
238   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)
239   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)
240   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)
241   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)
242
243   SET(SDL ${LIBDIR}/sdl)
244   SET(SDL_INC ${SDL}/include)
245   SET(SDL_LIB SDL)
246   SET(SDL_LIBPATH ${SDL}/lib)
247
248   SET(PNG "${LIBDIR}/png")
249   SET(PNG_INC "${PNG}/include")
250   SET(PNG_LIBPATH ${PNG}/lib)
251
252   SET(JPEG "${LIBDIR}/jpeg")
253   SET(JPEG_INC "${JPEG}/include")
254   SET(JPEG_LIBPATH ${JPEG}/lib)
255
256   SET(TIFF ${LIBDIR}/tiff)
257   SET(TIFF_INC ${TIFF}/include)
258   
259   SET(WINTAB_INC ${LIBDIR}/wintab/include) 
260
261   SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib")
262   SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib ")
263 ENDIF(WIN32)
264
265 IF(APPLE)
266   SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
267
268   INCLUDE(${CMAKE_ROOT}/Modules/FindOpenAL.cmake)
269   IF(OPENAL_FOUND)
270     SET(WITH_OPENAL ON)
271     SET(OPENAL_LIB ${OPENAL_LIBRARY})
272     SET(OPENAL_INC ${OPENAL_INCLUDE_DIR})
273   ELSE(OPENAL_FOUND)
274     SET(WITH_OPENAL OFF)
275   ENDIF(OPENAL_FOUND)
276
277   SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
278   SET(PYTHON_VERSION 2.3)
279   SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
280   SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION})
281   SET(PYTHON_LIB "")
282   SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
283   SET(PYTHON_LINKFLAGS "-u __dummy -u _PyMac_Error -framework System -framework Python")
284
285   SET(GETTEXT ${LIBDIR}/gettext)
286   SET(GETTEXT_INC "${GETTEXT}/include")
287   SET(GETTEXT_LIB intl iconv)
288   SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
289
290   SET(PNG_LIB png)
291   SET(JPEG_LIB jpeg)
292
293   SET(ZLIB /usr)
294   SET(ZLIB_INC "${ZLIB}/include")
295   SET(ZLIB_LIB z)
296
297   SET(FREETYPE ${LIBDIR}/freetype)
298   SET(FREETYPE_INC ${FREETYPE}/include ${FREETYPE}/include/freetype2)
299   SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
300   SET(FREETYPE_LIB freetype)
301
302   SET(OPENEXR ${LIBDIR}/openexr)
303   SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR)
304   SET(OPENEXR_LIB Iex Half IlmImf Imath)
305   SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
306
307   SET(LLIBS stdc++ SystemStubs)
308
309   SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
310   SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
311
312   SET(SDL ${LIBDIR}/sdl)
313   SET(SDL_INC ${SDL}/include)
314   SET(SDL_LIB SDL)
315   SET(SDL_LIBPATH ${SDL}/lib)
316
317   SET(PNG "${LIBDIR}/png")
318   SET(PNG_INC "${PNG}/include")
319   SET(PNG_LIBPATH ${PNG}/lib)
320
321   SET(JPEG "${LIBDIR}/jpeg")
322   SET(JPEG_INC "${JPEG}/include")
323   SET(JPEG_LIBPATH ${JPEG}/lib)
324
325   SET(TIFF ${LIBDIR}/tiff)
326   SET(TIFF_INC ${TIFF}/include)
327
328   SET(EXETYPE MACOSX_BUNDLE)
329 ENDIF(APPLE)
330
331 #-----------------------------------------------------------------------------
332 # Common.
333 SET(VERSE_INC ${CMAKE_SOURCE_DIR}/extern/verse/dist)
334
335 SET(FTGL ${CMAKE_SOURCE_DIR}/extern/bFTGL)
336 SET(FTGL_INC ${FTGL}/include)
337 SET(FTGL_LIB extern_ftgl)
338
339
340 #-----------------------------------------------------------------------------
341 # Configure OpenGL.
342 INCLUDE(${CMAKE_ROOT}/Modules/FindOpenGL.cmake)
343 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
344 #-----------------------------------------------------------------------------
345 # Extra compile flags
346 IF(WITH_GAMEENGINE)
347   SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DGAMEBLENDER ")
348 ENDIF(WITH_GAMEENGINE)
349 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ")
350 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ")
351
352 #-----------------------------------------------------------------------------
353 # Libraries
354 FILE(WRITE ${CMAKE_SOURCE_DIR}/cmake_blender_libs.txt "")
355 SUBDIRS(
356   intern
357   extern
358   source
359 )
360
361
362 #-----------------------------------------------------------------------------
363 # Blender Application
364 SUBDIRS(source/creator)
365
366 #-----------------------------------------------------------------------------
367 # Blender Player
368 IF(WITH_PLAYER)
369   SUBDIRS(blenderplayer)
370 ENDIF(WITH_PLAYER)