CMake lists initial submission. Documentationand further verification for different...
[blender-staging.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"                                          ON)
42 OPTION(WITH_GAMEENGINE          "Enable Game Engine"                                    ON)
43 OPTION(WITH_BULLET              "Enable Bullet (Physics Engine)"                        ON)
44 OPTION(WITH_INTERNATIONAL       "Enable I18N   (International fonts and text)"          ON)
45 OPTION(WITH_VERSE               "Enable Verse  (http://verse.blender.org)"              ON)
46 OPTION(WITH_ELBEEM              "Enable Elbeem (Fluid Simulation)"                      ON)
47 OPTION(WITH_QUICKTIME           "Enable Quicktime Support"                              ON)
48 OPTION(WITH_OPENEXR             "Enable OpenEXR Support (http://www.openexr.com)"       ON)
49
50 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
51   MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
52 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
53
54 #-----------------------------------------------------------------------------
55 # Load some macros.
56 INCLUDE(CMake/macros.cmake)
57
58 #-----------------------------------------------------------------------------
59 #Platform specifics
60
61 IF(UNIX)
62   INCLUDE(${CMAKE_ROOT}/Modules/FindOpenAL.cmake)
63   IF(OPENAL_FOUND)
64     SET(WITH_OPENAL ON)
65     SET(OPENAL_LIB ${OPENAL_LIBRARY})
66     SET(OPENAL_INC ${OPENAL_INCLUDE_DIR})
67   ELSE(OPENAL_FOUND)
68     SET(WITH_OPENAL OFF)
69   ENDIF(OPENAL_FOUND)
70
71   FIND_LIBRARY(ALUT_LIBRARY
72     NAMES alut
73     PATHS
74     /usr/local/lib
75     /usr/lib
76     /sw/lib
77     /opt/local/lib
78     /opt/csw/lib
79     /opt/lib
80   )
81   IF(ALUT_LIBRARY)
82     SET(OPENAL_LIB ${OPENAL_LIB} ${ALUT_LIBRARY})
83   ENDIF(ALUT_LIBRARY)
84
85   FIND_LIBRARY(INTL_LIBRARY
86     NAMES intl
87     PATHS
88     /usr/local/lib
89     /usr/lib
90     /sw/lib
91     /opt/local/lib
92     /opt/csw/lib
93     /opt/lib
94   )
95   FIND_LIBRARY(ICONV_LIBRARY
96     NAMES iconv
97     PATHS
98     /usr/local/lib
99     /usr/lib
100     /sw/lib
101     /opt/local/lib
102     /opt/csw/lib
103     /opt/lib
104   )
105   IF(INTL_LIBRARY AND ICONV_LIBRARY)
106     SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
107   ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
108   
109   FIND_PATH(FREETYPE_INC
110     freetype
111     PATHS
112     /usr/local/include/freetype2
113     /usr/include/freetype2
114     /sw/include/freetype2
115     /opt/local/include/freetype2
116     /opt/csw/include/freetype2
117     /opt/include/freetype2
118   )
119   SET(FREETYPE_LIB freetype)
120
121   INCLUDE(${CMAKE_ROOT}/Modules/FindPythonLibs.cmake)
122
123 # For FreeBSD (and possibly others) allow the commandline to override this to force Pyhon 2.3
124 # for instance. e.g:
125 # 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
126
127   SET(PYTHON_INC "${PYTHON_INCLUDE_PATH}" CACHE STRING "")
128   SET(PYTHON_LIB "${PYTHON_LIBRARIES}" CACHE STRING "")
129
130   INCLUDE(${CMAKE_ROOT}/Modules/FindPythonInterp.cmake)
131   SET(PYTHON_BINARY ${PYTHON_EXECUTABLE})
132   SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
133
134   INCLUDE(${CMAKE_ROOT}/Modules/FindSDL.cmake)
135   SET(SDL_INC ${SDL_INCLUDE_DIR})
136   SET(SDL_LIB ${SDL_LIBRARY})
137
138   FIND_PATH(OPENEXR_INC
139     ImfXdr.h
140     PATHS
141     /usr/local/include/OpenEXR
142     /usr/include/OpenEXR
143     /sw/include/OpenEXR
144     /opt/local/include/OpenEXR
145     /opt/csw/include/OpenEXR
146     /opt/include/OpenEXR
147   )
148   SET(OPENEXR_LIB Half IlmImf Iex Imath)
149
150   SET(JPEG_LIB jpeg)
151
152   SET(PNG_LIB png)
153
154   SET(ZLIB_LIB z)
155
156   SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++")
157
158   SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -DXP_UNIX -Wno-char-subscripts")
159
160   SET(PLATFORM_LINKFLAGS "-pthread")
161
162   INCLUDE_DIRECTORIES(/usr/include /usr/local/include)
163 ENDIF(UNIX)
164
165 IF(WIN32)
166   INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
167
168   SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
169
170   SET(PYTHON ${LIBDIR}/python)
171   SET(PYTHON_VERSION 2.4)
172   SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
173   SET(PYTHON_BINARY python)
174   SET(PYTHON_LIB python24)
175   SET(PYTHON_LIBPATH ${PYTHON}/lib)
176
177   SET(WITH_OPENAL ON)
178   SET(OPENAL ${LIBDIR}/openal)
179   SET(OPENAL_INC ${OPENAL}/include ${OPENAL}/include/AL)
180   SET(OPENAL_LIB openal_static)
181   SET(OPENAL_LIBPATH ${OPENAL}/lib)
182
183   SET(PNG_LIB libpng_st)
184   SET(JPEG_LIB libjpeg)
185
186   SET(ZLIB ${LIBDIR}/zlib)
187   SET(ZLIB_INC ${ZLIB}/include)
188   SET(ZLIB_LIB libz)
189   SET(ZLIB_LIBPATH ${ZLIB}/lib)
190   
191   SET(PTHREADS ${LIBDIR}/pthreads)
192   SET(PTHREADS_INC ${PTHREADS}/include)
193   SET(PTHREADS_LIB pthreadVC2)
194   SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
195   
196   SET(ICONV ${LIBDIR}/iconv)
197   SET(ICONV_INC ${ICONV}/include)
198   SET(ICONV_LIB iconv)
199   SET(ICONV_LIBPATH ${ICONV}/lib)
200   
201   SET(GETTEXT ${LIBDIR}/gettext)
202   SET(GETTEXT_INC ${GETTEXT}/include)
203   SET(GETTEXT_LIB gnu_gettext)
204   SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
205
206   SET(FREETYPE ${LIBDIR}/freetype)
207   SET(FREETYPE_INC ${FREETYPE}/include ${FREETYPE}/include/freetype2)
208   SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
209   SET(FREETYPE_LIB freetype2ST)
210   
211   SET(OPENEXR ${LIBDIR}/openexr)
212   SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
213   SET(OPENEXR_LIB Iex Half IlmImf Imath)
214   SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
215   
216   SET(QUICKTIME ${LIBDIR}/QTDevWin)
217   SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
218   SET(QUICKTIME_LIB qtmlClient)
219   SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
220
221   SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid odbc32 odbccp32 ws2_32 vfw32 winmm dxguid)
222
223   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)
224   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)
225   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)
226   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)
227   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)
228   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)
229   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)
230   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)
231
232   SET(SDL ${LIBDIR}/sdl)
233   SET(SDL_INC ${SDL}/include)
234   SET(SDL_LIB SDL)
235   SET(SDL_LIBPATH ${SDL}/lib)
236
237   SET(PNG "${LIBDIR}/png")
238   SET(PNG_INC "${PNG}/include")
239   SET(PNG_LIBPATH ${PNG}/lib)
240
241   SET(JPEG "${LIBDIR}/jpeg")
242   SET(JPEG_INC "${JPEG}/include")
243   SET(JPEG_LIBPATH ${JPEG}/lib)
244
245   SET(TIFF ${LIBDIR}/tiff)
246   SET(TIFF_INC ${TIFF}/include)
247   
248   SET(WINTAB_INC ${LIBDIR}/wintab/include) 
249
250   SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib")
251   SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib ")
252 ENDIF(WIN32)
253
254 IF(APPLE)
255   SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
256
257   INCLUDE(${CMAKE_ROOT}/Modules/FindOpenAL.cmake)
258   IF(OPENAL_FOUND)
259     SET(WITH_OPENAL ON)
260     SET(OPENAL_LIB ${OPENAL_LIBRARY})
261     SET(OPENAL_INC ${OPENAL_INCLUDE_DIR})
262   ELSE(OPENAL_FOUND)
263     SET(WITH_OPENAL OFF)
264   ENDIF(OPENAL_FOUND)
265
266   SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
267   SET(PYTHON_VERSION 2.3)
268   SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
269   SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION})
270   SET(PYTHON_LIB "")
271   SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
272   SET(PYTHON_LINKFLAGS "-u __dummy -u _PyMac_Error -framework System -framework Python")
273
274   SET(GETTEXT ${LIBDIR}/gettext)
275   SET(GETTEXT_INC "${GETTEXT}/include")
276   SET(GETTEXT_LIB intl iconv)
277   SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
278
279   SET(PNG_LIB png)
280   SET(JPEG_LIB jpeg)
281
282   SET(ZLIB /usr)
283   SET(ZLIB_INC "${ZLIB}/include")
284   SET(ZLIB_LIB z)
285
286   SET(FREETYPE ${LIBDIR}/freetype)
287   SET(FREETYPE_INC ${FREETYPE}/include ${FREETYPE}/include/freetype2)
288   SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
289   SET(FREETYPE_LIB freetype)
290
291   SET(OPENEXR ${LIBDIR}/openexr)
292   SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR)
293   SET(OPENEXR_LIB Iex Half IlmImf Imath)
294   SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
295
296   SET(LLIBS stdc++ SystemStubs)
297
298   SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
299   SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
300
301   SET(SDL ${LIBDIR}/sdl)
302   SET(SDL_INC ${SDL}/include)
303   SET(SDL_LIB SDL)
304   SET(SDL_LIBPATH ${SDL}/lib)
305
306   SET(PNG "${LIBDIR}/png")
307   SET(PNG_INC "${PNG}/include")
308   SET(PNG_LIBPATH ${PNG}/lib)
309
310   SET(JPEG "${LIBDIR}/jpeg")
311   SET(JPEG_INC "${JPEG}/include")
312   SET(JPEG_LIBPATH ${JPEG}/lib)
313
314   SET(TIFF ${LIBDIR}/tiff)
315   SET(TIFF_INC ${TIFF}/include)
316
317   SET(EXETYPE MACOSX_BUNDLE)
318 ENDIF(APPLE)
319
320 #-----------------------------------------------------------------------------
321 # Common.
322 SET(VERSE_INC ${CMAKE_SOURCE_DIR}/extern/verse/dist)
323
324 SET(FTGL ${CMAKE_SOURCE_DIR}/extern/bFTGL)
325 SET(FTGL_INC ${FTGL}/include)
326 SET(FTGL_LIB extern_ftgl)
327
328
329 #-----------------------------------------------------------------------------
330 # Configure OpenGL.
331 INCLUDE(${CMAKE_ROOT}/Modules/FindOpenGL.cmake)
332 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
333 #-----------------------------------------------------------------------------
334 # Extra compile flags
335 IF(WITH_GAMEENGINE)
336   SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DGAMEBLENDER ")
337 ENDIF(WITH_GAMEENGINE)
338 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ")
339 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ")
340
341 #-----------------------------------------------------------------------------
342 # Libraries
343 FILE(WRITE ${CMAKE_SOURCE_DIR}/cmake_blender_libs.txt "")
344 SUBDIRS(
345   intern
346   extern
347   source
348 )
349
350
351 #-----------------------------------------------------------------------------
352 # Blender Application
353 SUBDIRS(source/creator)
354
355 #-----------------------------------------------------------------------------
356 # Blender Player
357 IF(WITH_PLAYER)
358   SUBDIRS(blenderplayer)
359 ENDIF(WITH_PLAYER)