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