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