revert r32284, turns out OpenSuse needs this for forkpty(), also fixed missing impor...
[blender.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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.6)
46
47 # quiet output for Makefiles, 'make -s' helps too
48 # SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES OFF)
49
50 PROJECT(Blender)
51
52 #-----------------------------------------------------------------------------
53 # Redirect output files
54
55 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
56 SET(LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
57
58 #-----------------------------------------------------------------------------
59 # Load some macros.
60 INCLUDE(build_files/cmake/macros.cmake)
61
62 #-----------------------------------------------------------------------------
63 # Set default config options
64
65 GET_BLENDER_VERSION()
66
67 # Blender internal features
68 OPTION(WITH_INTERNATIONAL "Enable I18N   (International fonts and text)" ON)
69 OPTION(WITH_LCMS          "Enable color correction with lcms" OFF)
70 OPTION(WITH_PYTHON        "Enable Embedded Python API" ON)
71 OPTION(WITH_BUILDINFO     "Include extra build details" ON)
72 OPTION(WITH_FLUID        "Enable Elbeem (Fluid Simulation)" ON)
73 OPTION(WITH_IK_ITASC      "Enable ITASC IK solver" ON)
74 OPTION(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
75 OPTION(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
76 OPTION(WITH_GAMEENGINE    "Enable Game Engine" ON)
77 OPTION(WITH_PLAYER        "Build Player" OFF)
78 # (unix defaults to OpenMP On)
79 IF(UNIX AND NOT APPLE)
80         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
81 ELSE()
82         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
83 ENDIF()
84
85 # Image format support
86 OPTION(WITH_IMAGE_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
87 OPTION(WITH_IMAGE_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org/)" OFF)
88 OPTION(WITH_IMAGE_TIFF          "Enable LibTIFF Support" ON)
89 OPTION(WITH_IMAGE_DDS           "Enable DDS Image Support" ON)
90 OPTION(WITH_IMAGE_CINEON        "Enable CINEON and DPX Image Support" ON)
91 OPTION(WITH_IMAGE_HDR           "Enable HDR Image Support" ON)
92
93 # Audio format support
94 OPTION(WITH_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF)
95 OPTION(WITH_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
96 IF(APPLE OR WIN32)
97         OPTION(WITH_QUICKTIME     "Enable Quicktime Support" OFF)
98 ENDIF(APPLE OR WIN32)
99
100 # 3D format support
101 # disable opencollada on non-apple unix because opencollada has no package for debian
102 IF(UNIX AND NOT APPLE)
103         OPTION(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org/)"      OFF)
104 ELSE()
105         OPTION(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org/)"      OFF)
106 ENDIF()
107
108 # Sound output
109 OPTION(WITH_SDL           "Enable SDL for sound and joystick support" ON)
110 OPTION(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
111 OPTION(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
112
113 # Compression
114 OPTION(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
115 OPTION(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
116
117 # Misc
118 OPTION(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" ON) 
119 OPTION(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking" OFF)
120 OPTION(WITH_INSTALL       "Install accompanying scripts and language files needed to run blender" ON)
121 OPTION(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
122
123 IF(APPLE)
124         OPTION(WITH_COCOA         "Use Cocoa framework instead of deprecated Carbon" ON)
125         OPTION(USE_QTKIT          "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
126         OPTION(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
127 ENDIF(APPLE)
128
129 IF(NOT WITH_BULLET AND WITH_GAMEENGINE)
130         MESSAGE("WARNING: WITH_GAMEENGINE needs WITH_BULLET")
131 ENDIF(NOT WITH_BULLET AND WITH_GAMEENGINE)
132
133 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
134         MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
135 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
136
137 IF(NOT WITH_INSTALL AND WITH_PYTHON_INSTALL)
138         MESSAGE("WARNING: WITH_PYTHON_INSTALL needs WITH_INSTALL")
139 ENDIF(NOT WITH_INSTALL AND WITH_PYTHON_INSTALL)
140
141 TEST_SSE_SUPPORT()
142
143 # disabled for now, not supported
144 # OPTION(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
145
146 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
147 # On Unix: 
148 #   cmake -D PYTHON_LIB=/usr/local/lib/python3.1/config/libpython3.1.so -D PYTHON_INC=/usr/local/include/python3.1 -G "Unix Makefiles" ../blender
149 # On Macs: 
150 #   cmake -D PYTHON_INC=/System/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/config -G Xcode ../blender
151 #
152 # When changing any of this remember to update the notes in doc/blender-cmake.txt
153
154 #-----------------------------------------------------------------------------
155 #Platform specifics
156
157 IF(UNIX AND NOT APPLE)
158
159         IF(WITH_OPENAL)
160                 FIND_PACKAGE(OpenAL)
161                 IF(NOT OPENAL_FOUND)
162                         SET(WITH_OPENAL OFF)
163                 ENDIF(NOT OPENAL_FOUND)
164         ENDIF(WITH_OPENAL)
165
166         IF(WITH_JACK)
167                 SET(JACK /usr)
168                 SET(JACK_INC ${JACK}/include/jack)
169                 SET(JACK_LIB jack)
170                 SET(JACK_LIBPATH ${JACK}/lib)
171         ENDIF(WITH_JACK)
172
173         IF(WITH_SNDFILE)
174         SET(SNDFILE /usr)
175         SET(SNDFILE_INC ${SNDFILE}/include)
176         SET(SNDFILE_LIB sndfile)
177         SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
178         ENDIF(WITH_SNDFILE)
179
180         IF(WITH_INTERNATIONAL)
181                 FIND_LIBRARY(INTL_LIBRARY
182                         NAMES intl
183                         PATHS
184                         /sw/lib
185                 )
186
187                 FIND_LIBRARY(ICONV_LIBRARY
188                         NAMES iconv
189                         PATHS
190                         /sw/lib
191                 )
192
193                 IF(INTL_LIBRARY AND ICONV_LIBRARY)
194                         SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
195                 ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
196         ENDIF(WITH_INTERNATIONAL)
197
198         FIND_PACKAGE(Freetype)
199         # UNSET(FREETYPE_INCLUDE_DIRS CACHE) # cant use
200
201
202         IF(WITH_PYTHON)
203                 # No way to set py31. remove for now.
204                 # FIND_PACKAGE(PythonLibs)
205                 SET(PYTHON /usr)
206                 SET(PYTHON_VERSION 3.1)
207                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
208                 # SET(PYTHON_BINARY python) # not used yet
209                 SET(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "")
210                 SET(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "")
211         
212                 # FIND_PACKAGE(PythonInterp) # not used yet
213                 # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
214
215                 SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
216         ENDIF(WITH_PYTHON)
217
218         IF(WITH_SDL)
219                 FIND_PACKAGE(SDL)
220                 # UNSET(SDLMAIN_LIBRARY CACHE)
221                 IF(NOT SDL_FOUND)
222                         SET(WITH_SDL OFF)
223                 ENDIF(NOT SDL_FOUND)
224         ENDIF(WITH_SDL)
225
226         IF(WITH_IMAGE_OPENEXR)
227                 SET(OPENEXR /usr CACHE FILEPATH "OPENEXR Directory")
228                 FIND_PATH(OPENEXR_INC
229                         ImfXdr.h
230                         PATHS
231                         ${OPENEXR}/include/OpenEXR
232                         /usr/local/include/OpenEXR
233                         /sw/include/OpenEXR
234                         /opt/local/include/OpenEXR
235                         /opt/csw/include/OpenEXR
236                         /opt/include/OpenEXR
237                 )
238                 SET(OPENEXR_LIB Half IlmImf Iex Imath)
239                 
240                 IF(NOT OPENEXR_INC)
241                         SET(WITH_IMAGE_OPENEXR OFF)
242                 ENDIF(NOT OPENEXR_INC)
243         ENDIF(WITH_IMAGE_OPENEXR)
244
245         IF(WITH_IMAGE_TIFF)
246                 FIND_PACKAGE(TIFF)
247                 IF(NOT TIFF_FOUND)
248                         SET(WITH_IMAGE_TIFF OFF)
249                 ENDIF(NOT TIFF_FOUND)
250         ENDIF(WITH_IMAGE_TIFF)
251
252         FIND_PACKAGE(JPEG REQUIRED)
253
254         FIND_PACKAGE(PNG REQUIRED)
255
256         FIND_PACKAGE(ZLIB REQUIRED)
257
258         IF(WITH_LCMS)
259                 SET(LCMS /usr CACHE FILEPATH "LCMS directory")
260                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
261                 SET(LCMS_LIBRARY lcms)
262                 SET(LCMS_LIBPATH ${LCMS}/lib)
263         ENDIF(WITH_LCMS)
264
265         IF(WITH_FFMPEG)
266                 SET(FFMPEG /usr CACHE FILEPATH "FFMPEG Directory")
267                 SET(FFMPEG_INC ${FFMPEG}/include)
268                 SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
269                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
270                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
271         ENDIF(WITH_FFMPEG)
272
273         IF(WITH_FFTW3)
274                 SET(FFTW3 /usr)
275                 SET(FFTW3_INC ${FFTW3}/include)
276                 SET(FFTW3_LIB fftw3)
277                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
278         ENDIF(WITH_FFTW3)
279
280         SET(LIBSAMPLERATE /usr)
281         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
282         SET(LIBSAMPLERATE_LIB samplerate)
283         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
284
285         IF (WITH_OPENCOLLADA)
286                 SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
287                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
288                 SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer)
289                 SET(OPENCOLLADA_INC ${OPENCOLLADA})
290                 SET(PCRE /usr CACHE FILEPATH "PCRE Directory")
291                 SET(PCRE_LIBPATH ${PCRE}/lib)
292                 SET(PCRE_LIB pcre)
293                 SET(EXPAT /usr CACHE FILEPATH "Expat Directory")
294                 SET(EXPAT_LIBPATH ${EXPAT}/lib)
295                 SET(EXPAT_LIB expat)
296         ENDIF (WITH_OPENCOLLADA)
297
298         FIND_PACKAGE(X11 REQUIRED)
299
300         # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
301         SET(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB} ${X11_Xinput_LIB}")
302
303         IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
304                 # BSD's dont use libdl.so
305                 LIST(APPEND LLIBS -ldl)
306
307                 # binreloc is linux only
308                 SET(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
309                 SET(BINRELOC_INC ${BINRELOC}/include)
310         ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
311
312         IF(WITH_OPENMP)
313                 LIST(APPEND LLIBS -lgomp)
314                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
315                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
316         ENDIF(WITH_OPENMP)
317
318
319         SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
320
321         SET(PLATFORM_LINKFLAGS "-pthread")
322
323         # Better warnings
324         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
325         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
326
327         INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
328 ENDIF(UNIX AND NOT APPLE)
329
330
331 IF(WIN32)
332
333         # this file is included anyway when building under Windows with cl.exe
334         #  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
335   
336         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
337
338         # Setup 64bit and 64bit windows systems
339         IF(CMAKE_CL_64)
340                 message("64 bit compiler detected.")
341                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
342         ENDIF(CMAKE_CL_64)
343         
344         ADD_DEFINITIONS(-DWIN32)
345
346         IF(WITH_INTERNATIONAL)
347                 SET(ICONV ${LIBDIR}/iconv)
348                 SET(ICONV_INC ${ICONV}/include)
349                 SET(ICONV_LIB iconv)
350                 SET(ICONV_LIBPATH ${ICONV}/lib)
351         ENDIF(WITH_INTERNATIONAL)
352
353         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
354         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
355         SET(LIBSAMPLERATE_LIB libsamplerate)
356         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
357
358         SET(PNG "${LIBDIR}/png")
359         SET(PNG_INC "${PNG}/include")
360         SET(PNG_LIBPATH ${PNG}/lib)
361
362         SET(JPEG "${LIBDIR}/jpeg")
363         SET(JPEG_INC "${JPEG}/include")
364         SET(JPEG_LIBPATH ${JPEG}/lib)
365
366         SET(WINTAB_INC ${LIBDIR}/wintab/include) 
367
368         IF(WITH_OPENAL)
369                 SET(OPENAL ${LIBDIR}/openal)
370                 SET(OPENAL_INCLUDE_DIR ${OPENAL}/include)
371                 SET(OPENAL_LIBRARY wrap_oal)
372                 SET(OPENAL_LIBPATH ${OPENAL}/lib)
373         ENDIF(WITH_OPENAL)
374
375         IF(WITH_SNDFILE)
376                 SET(SNDFILE ${LIBDIR}/sndfile)
377                 SET(SNDFILE_INC ${SNDFILE}/include)
378                 SET(SNDFILE_LIB libsndfile-1)
379                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
380         ENDIF(WITH_SNDFILE)
381
382         IF(WITH_SDL)
383                 SET(SDL ${LIBDIR}/sdl)
384                 SET(SDL_INCLUDE_DIR ${SDL}/include)
385                 SET(SDL_LIBRARY SDL)
386                 SET(SDL_LIBPATH ${SDL}/lib)
387         ENDIF(WITH_SDL)
388
389         IF(WITH_QUICKTIME)
390                 SET(QUICKTIME ${LIBDIR}/QTDevWin)
391                 SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
392                 SET(QUICKTIME_LIB qtmlClient)
393                 SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
394         ENDIF(WITH_QUICKTIME)
395
396         IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
397                 ADD_DEFINITIONS(-D__SSE__ -D__MMX__)
398         ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
399
400         IF(MSVC)
401                 IF(CMAKE_CL_64)
402                         SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
403                 ELSE(CMAKE_CL_64)
404                         SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
405                 ENDIF(CMAKE_CL_64)
406                 
407                 SET(CMAKE_CXX_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305" CACHE STRING "MSVC MT C++ flags " FORCE)
408                 SET(CMAKE_C_FLAGS   "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305" CACHE STRING "MSVC MT C++ flags " FORCE)
409
410                 IF(CMAKE_CL_64)
411                         SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
412                 ELSE(CMAKE_CL_64)
413                         SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
414                 ENDIF(CMAKE_CL_64)
415                 SET(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
416                 SET(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
417                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
418                 IF(CMAKE_CL_64)
419                         SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
420                 ELSE(CMAKE_CL_64)
421                         SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
422                 ENDIF(CMAKE_CL_64)
423                 SET(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
424                 SET(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
425                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
426                 
427                 IF(WITH_OPENMP)
428                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp ")
429                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp ")
430                 ENDIF(WITH_OPENMP)
431                 
432                 IF(WITH_INTERNATIONAL)
433                         SET(GETTEXT ${LIBDIR}/gettext)
434                         SET(GETTEXT_INC ${GETTEXT}/include)
435                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
436                         IF(CMAKE_CL_64)
437                                 SET(GETTEXT_LIB gettext)
438                         ELSE(CMAKE_CL_64)
439                                 SET(GETTEXT_LIB gnu_gettext)
440                         ENDIF(CMAKE_CL_64)
441                 ENDIF(WITH_INTERNATIONAL)
442
443                 IF(CMAKE_CL_64)
444                         SET(PNG_LIBRARIES libpng)
445                 ELSE(CMAKE_CL_64)
446                         SET(PNG_LIBRARIES libpng_st)
447                 ENDIF(CMAKE_CL_64)
448                 SET(JPEG_LIBRARY libjpeg)
449
450                 SET(ZLIB ${LIBDIR}/zlib)
451                 SET(ZLIB_INC ${ZLIB}/include)
452                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
453                 IF(CMAKE_CL_64)
454                         SET(ZLIB_LIBRARIES libz)
455                 ELSE(CMAKE_CL_64)
456                         SET(ZLIB_LIBRARIES zlib)
457                 ENDIF(CMAKE_CL_64)
458
459                 SET(PTHREADS ${LIBDIR}/pthreads)
460                 SET(PTHREADS_INC ${PTHREADS}/include)
461                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
462                 SET(PTHREADS_LIB pthreadVC2)
463                 
464                 SET(FREETYPE ${LIBDIR}/freetype)
465                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
466                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
467                 SET(FREETYPE_LIBRARY freetype2ST)
468
469                 IF(WITH_FFTW3)
470                         SET(FFTW3 ${LIBDIR}/fftw3)
471                         SET(FFTW3_LIB libfftw)
472                         SET(FFTW3_INC ${FFTW3}/include)
473                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
474                 ENDIF(WITH_FFTW3)
475
476                 IF(WITH_OPENCOLLADA)
477                         SET(OPENCOLLADA ${LIBDIR}/opencollada)
478                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
479                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
480                         SET(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa)
481                         #pcre is bundled with openCollada
482                         #SET(PCRE ${LIBDIR}/pcre)
483                         #SET(PCRE_LIBPATH ${PCRE}/lib)
484                         SET(PCRE_LIB pcre)
485                 ENDIF(WITH_OPENCOLLADA)
486                 
487                 # TODO: IF(WITH_LCMS)
488         
489                 IF(WITH_FFMPEG)
490                         SET(FFMPEG ${LIBDIR}/ffmpeg)
491                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include/msvc)
492                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
493                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
494                 ENDIF(WITH_FFMPEG)
495
496                 IF(WITH_IMAGE_OPENEXR)
497                         SET(OPENEXR ${LIBDIR}/openexr)
498                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
499                         SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
500                         IF (MSVC80)
501                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
502                         ELSE (MSVC80)
503                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
504                         ENDIF(MSVC80)
505                         IF (MSVC90)
506                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
507                         ENDIF(MSVC90)
508                 ENDIF(WITH_IMAGE_OPENEXR)
509
510                 IF(WITH_IMAGE_TIFF)
511                         SET(TIFF ${LIBDIR}/tiff)
512                         SET(TIFF_LIBRARY libtiff)
513                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
514                         SET(TIFF_LIBPATH ${TIFF}/lib)
515                 ENDIF(WITH_IMAGE_TIFF)
516
517                 IF(WITH_JACK)
518                         SET(JACK ${LIBDIR}/jack)
519                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
520                         SET(JACK_LIB libjack)
521                         SET(JACK_LIBPATH ${JACK}/lib)
522                 ENDIF(WITH_JACK)
523
524                 IF(WITH_PYTHON)
525                         SET(PYTHON ${LIBDIR}/python)
526                         SET(PYTHON_VERSION 3.1)
527                         SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
528                         # SET(PYTHON_BINARY python) # not used yet
529                         SET(PYTHON_LIB python31)
530                         SET(PYTHON_LIBPATH ${PYTHON}/lib)
531                 ENDIF(WITH_PYTHON)
532
533                 # MSVC only, Mingw doesnt need
534                 IF(CMAKE_CL_64)
535                         SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
536                 ELSE(CMAKE_CL_64)
537                         SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
538                 ENDIF(CMAKE_CL_64)
539           
540                 SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
541
542         ELSE(MSVC) # MINGW
543                 SET(LLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid")
544                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
545
546                 # Better warnings
547                 SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
548                 SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
549
550                 ADD_DEFINITIONS(-DFREE_WINDOWS)
551
552                 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
553                 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
554
555
556                 SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
557                 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
558
559                 SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG")
560                 SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
561
562                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG")
563                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DNDEBUG")
564
565
566                 IF(WITH_OPENMP)
567                         SET(LLIBS "${LLIBS} -lgomp")
568                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
569                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
570                 ENDIF(WITH_OPENMP)
571
572                 IF(WITH_INTERNATIONAL)
573                         SET(GETTEXT ${LIBDIR}/gcc/gettext)
574                         SET(GETTEXT_INC ${GETTEXT}/include)
575                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
576                         SET(GETTEXT_LIB intl)
577                 ENDIF(WITH_INTERNATIONAL)
578
579                 SET(JPEG_LIBRARY libjpeg)
580                 SET(PNG_LIBRARIES png)
581
582                 SET(ZLIB ${LIBDIR}/zlib)
583                 SET(ZLIB_INC ${ZLIB}/include)
584                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
585                 SET(ZLIB_LIBRARIES z)
586
587                 SET(PTHREADS ${LIBDIR}/pthreads)
588                 SET(PTHREADS_INC ${PTHREADS}/include)
589                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
590                 SET(PTHREADS_LIB pthreadGC2)
591                 
592                 SET(FREETYPE ${LIBDIR}/gcc/freetype)
593                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
594                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
595                 SET(FREETYPE_LIBRARY freetype)
596
597                 IF(WITH_FFTW3)
598                         SET(FFTW3 ${LIBDIR}/gcc/fftw3)
599                         SET(FFTW3_LIB fftw3)
600                         SET(FFTW3_INC ${FFTW3}/include)
601                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
602                 ENDIF(WITH_FFTW3)
603
604                 IF(WITH_OPENCOLLADA)
605                         SET(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
606                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
607                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
608                         SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
609                         #pcre is bundled with openCollada
610                         #SET(PCRE ${LIBDIR}/pcre)
611                         #SET(PCRE_LIBPATH ${PCRE}/lib)
612                         SET(PCRE_LIB pcre)
613                 ENDIF(WITH_OPENCOLLADA)
614                 
615                 IF(WITH_FFMPEG)
616                         SET(FFMPEG ${LIBDIR}/ffmpeg)
617                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include)
618                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
619                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
620                 ENDIF(WITH_FFMPEG)
621
622                 IF(WITH_IMAGE_OPENEXR)
623                         SET(OPENEXR ${LIBDIR}/gcc/openexr)
624                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR)
625                         SET(OPENEXR_LIB Half IlmImf Imath IlmThread)
626                         SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
627
628                         # TODO, gives linking errors, force off
629                         SET(WITH_IMAGE_OPENEXR OFF)
630                 ENDIF(WITH_IMAGE_OPENEXR)
631
632                 IF(WITH_IMAGE_TIFF)
633                         SET(TIFF ${LIBDIR}/gcc/tiff)
634                         SET(TIFF_LIBRARY tiff)
635                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
636                         SET(TIFF_LIBPATH ${TIFF}/lib)
637                 ENDIF(WITH_IMAGE_TIFF)
638
639                 IF(WITH_JACK)
640                         SET(JACK ${LIBDIR}/jack)
641                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
642                         SET(JACK_LIB jack)
643                         SET(JACK_LIBPATH ${JACK}/lib)
644                         
645                         # TODO, gives linking errors, force off
646                         SET(WITH_JACK OFF)
647                 ENDIF(WITH_JACK)
648
649                 IF(WITH_PYTHON)
650                         SET(PYTHON ${LIBDIR}/python)
651                         SET(PYTHON_VERSION 3.1)
652                         SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
653                         # SET(PYTHON_BINARY python) # not used yet
654                         SET(PYTHON_LIB python31mw)
655                         SET(PYTHON_LIBPATH ${PYTHON}/lib)
656                 ENDIF(WITH_PYTHON)
657
658         ENDIF(MSVC)
659
660 ENDIF(WIN32)
661
662
663 IF(APPLE)
664         IF(WITH_LIBS10.5)
665                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
666         ELSE(WITH_LIBS10.5)
667                 IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
668                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
669                 ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
670                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
671                 ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
672         ENDIF(WITH_LIBS10.5)
673         
674
675         IF(WITH_OPENAL)
676                 FIND_PACKAGE(OpenAL)
677                 IF(OPENAL_FOUND)
678                         SET(WITH_OPENAL ON)
679                         SET(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
680                 ELSE(OPENAL_FOUND)
681                         SET(WITH_OPENAL OFF)
682                 ENDIF(OPENAL_FOUND)
683         ENDIF(WITH_OPENAL)
684
685         IF(WITH_JACK)
686                 SET(JACK /usr)
687                 SET(JACK_INC ${JACK}/include/jack)
688                 SET(JACK_LIB jack)
689                 SET(JACK_LIBPATH ${JACK}/lib)
690         ENDIF(WITH_JACK)
691
692         IF(WITH_SNDFILE)
693                 SET(SNDFILE ${LIBDIR}/sndfile)
694                 SET(SNDFILE_INC ${SNDFILE}/include)
695                 SET(SNDFILE_LIB sndfile FLAC ogg vorbis vorbisenc)
696                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)
697         ENDIF(WITH_SNDFILE)
698
699         SET(PYTHON_VERSION 3.1)
700
701         IF(PYTHON_VERSION MATCHES 3.1)
702                 # we use precompiled libraries for py 3.1 and up by default
703
704                 SET(PYTHON ${LIBDIR}/python)
705                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
706                 # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
707                 SET(PYTHON_LIB python${PYTHON_VERSION})
708                 SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
709                 # SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
710         ELSE(PYTHON_VERSION MATCHES 3.1)
711                 # otherwise, use custom system framework
712
713                 SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
714                 SET(PYTHON_VERSION 3.1)
715                 SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
716                 # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
717                 SET(PYTHON_LIB "")
718                 SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
719                 SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
720         ENDIF(PYTHON_VERSION MATCHES 3.1)
721
722         IF(WITH_INTERNATIONAL)
723                 SET(GETTEXT ${LIBDIR}/gettext)
724                 SET(GETTEXT_INC "${GETTEXT}/include")
725                 SET(GETTEXT_LIB intl iconv)
726                 SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
727         ENDIF(WITH_INTERNATIONAL)
728   
729         IF(WITH_FFTW3)
730                 SET(FFTW3 ${LIBDIR}/fftw3)
731                 SET(FFTW3_INC ${FFTW3}/include)
732                 SET(FFTW3_LIB fftw3)
733                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
734         ENDIF(WITH_FFTW3)
735
736         SET(PNG_LIBRARIES png)
737         SET(JPEG_LIBRARY jpeg)
738
739         SET(ZLIB /usr)
740         SET(ZLIB_INC "${ZLIB}/include")
741         SET(ZLIB_LIBRARIES z bz2)
742
743         SET(FREETYPE ${LIBDIR}/freetype)
744         SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
745         SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
746         SET(FREETYPE_LIBRARY freetype)
747
748         IF(WITH_IMAGE_OPENEXR)
749                 SET(OPENEXR ${LIBDIR}/openexr)
750                 SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
751                 SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
752                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
753         ENDIF(WITH_IMAGE_OPENEXR)
754
755         IF(WITH_LCMS)
756                 SET(LCMS ${LIBDIR}/lcms)
757                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
758                 SET(LCMS_LIBRARY lcms)
759                 SET(LCMS_LIBPATH ${LCMS}/lib)
760         ENDIF(WITH_LCMS)
761
762         IF(WITH_FFMPEG)
763                 SET(FFMPEG ${LIBDIR}/ffmpeg)
764                 SET(FFMPEG_INC ${FFMPEG}/include)
765                 SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
766                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
767                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
768         ENDIF(WITH_FFMPEG)
769
770         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
771         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
772         SET(LIBSAMPLERATE_LIB samplerate)
773         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
774
775         SET(LLIBS stdc++ SystemStubs)
776
777         IF (WITH_COCOA)
778                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
779                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
780                 IF(USE_QTKIT)
781                         SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
782                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
783                         IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
784                                 SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
785                                 #libSDL still needs 32bit carbon quicktime 
786                         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
787                 ELSEIF(WITH_QUICKTIME)
788                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
789                 ENDIF(USE_QTKIT)
790         ELSE (WITH_COCOA)
791                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char")
792                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
793         ENDIF (WITH_COCOA)
794
795         IF(WITH_OPENMP)
796                 SET(LLIBS "${LLIBS} -lgomp")
797                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
798                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
799         ENDIF(WITH_OPENMP)
800
801         IF (WITH_OPENCOLLADA)
802                 SET(OPENCOLLADA ${LIBDIR}/opencollada)
803                 SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
804                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
805                 SET(OPENCOLLADA_LIB "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
806                 #pcre is bundled with openCollada
807                 #SET(PCRE ${LIBDIR}/pcre)
808                 #SET(PCRE_LIBPATH ${PCRE}/lib)
809                 SET(PCRE_LIB pcre)
810                 #libxml2 is used
811                 #SET(EXPAT ${LIBDIR}/expat)
812                 #SET(EXPAT_LIBPATH ${EXPAT}/lib)
813                 SET(EXPAT_LIB)
814         ENDIF (WITH_OPENCOLLADA)
815
816         IF(WITH_SDL)
817                 SET(SDL ${LIBDIR}/sdl)
818                 SET(SDL_INCLUDE_DIR ${SDL}/include)
819                 SET(SDL_LIBRARY SDL)
820                 SET(SDL_LIBPATH ${SDL}/lib)
821         ENDIF(WITH_SDL)
822
823         SET(PNG "${LIBDIR}/png")
824         SET(PNG_INC "${PNG}/include")
825         SET(PNG_LIBPATH ${PNG}/lib)
826
827         SET(JPEG "${LIBDIR}/jpeg")
828         SET(JPEG_INC "${JPEG}/include")
829         SET(JPEG_LIBPATH ${JPEG}/lib)
830
831         IF(WITH_IMAGE_TIFF)
832                 SET(TIFF ${LIBDIR}/tiff)
833                 SET(TIFF_INCLUDE_DIR ${TIFF}/include)
834                 SET(TIFF_LIBRARY tiff)
835                 SET(TIFF_LIBPATH ${TIFF}/lib)
836         ENDIF(WITH_IMAGE_TIFF)
837
838         SET(EXETYPE MACOSX_BUNDLE)
839
840         SET(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
841         SET(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
842         IF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
843                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
844                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
845         ELSEIF(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
846                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
847                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
848         ELSE(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
849                 SET(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
850                 SET(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
851         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
852
853         # Better warnings
854         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
855         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
856
857 ENDIF(APPLE)
858
859
860 # buildinfo
861 IF(WITH_BUILDINFO)
862         # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
863         IF(UNIX)
864                 EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
865                 EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)  
866                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
867                 IF(BUILD_REV_RETURN)
868                         SET(BUILD_REV "unknown")
869                 ENDIF(BUILD_REV_RETURN)
870         ENDIF(UNIX)
871         
872         IF(WIN32)
873                 EXEC_PROGRAM("cmd /c date /t" OUTPUT_VARIABLE BUILD_DATE)
874                 EXEC_PROGRAM("cmd /c time /t" OUTPUT_VARIABLE BUILD_TIME)  
875                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
876                 IF(BUILD_REV_RETURN)
877                         SET(BUILD_REV "unknown")
878                 ENDIF(BUILD_REV_RETURN)
879         ENDIF(WIN32)
880 ENDIF(WITH_BUILDINFO)
881 #-----------------------------------------------------------------------------
882 # Common.
883
884 IF(WITH_RAYOPTIMIZATION)
885         IF(CMAKE_COMPILER_IS_GNUCC)
886                 IF(SUPPORT_SSE_BUILD)
887                         SET(PLATFORM_CFLAGS " -msse ${PLATFORM_CFLAGS}")
888                         ADD_DEFINITIONS(-D__SSE__ -D__MMX__)
889                 ENDIF(SUPPORT_SSE_BUILD)
890                 IF(SUPPORT_SSE2_BUILD)
891                         SET(PLATFORM_CFLAGS " -msse2 ${PLATFORM_CFLAGS}")
892                         ADD_DEFINITIONS(-D__SSE2__)
893                         IF(NOT SUPPORT_SSE_BUILD) # dont double up
894                                 ADD_DEFINITIONS(-D__MMX__)
895                         ENDIF(NOT SUPPORT_SSE_BUILD)
896                 ENDIF(SUPPORT_SSE2_BUILD)
897         ENDIF(CMAKE_COMPILER_IS_GNUCC)
898 ENDIF(WITH_RAYOPTIMIZATION)
899
900 IF(WITH_IMAGE_OPENJPEG)
901         set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
902         set(OPENJPEG_INC ${OPENJPEG})
903         set(OPENJPEG_LIb extern_openjpeg)
904 ENDIF(WITH_IMAGE_OPENJPEG)
905
906 #-----------------------------------------------------------------------------
907 # Blender WebPlugin
908
909 IF(WITH_WEBPLUGIN) 
910         SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
911         SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
912
913         SET(WITH_PLAYER ON)
914 ENDIF(WITH_WEBPLUGIN)
915
916
917 #-----------------------------------------------------------------------------
918 # Configure OpenGL.
919 FIND_PACKAGE(OpenGL)
920 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
921 # UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
922 # UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
923
924 #-----------------------------------------------------------------------------
925 # Extra compile flags
926 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
927 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
928
929 # better not define flags here but this is a debugging option thats off by default.
930 IF(WITH_CXX_GUARDEDALLOC)
931         SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
932 ENDIF(WITH_CXX_GUARDEDALLOC)
933
934 #-----------------------------------------------------------------------------
935 # Libraries
936 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
937 ADD_SUBDIRECTORY(intern)
938 ADD_SUBDIRECTORY(extern)
939 ADD_SUBDIRECTORY(source)
940
941
942 #-----------------------------------------------------------------------------
943 # Blender Application
944 ADD_SUBDIRECTORY(source/creator)
945
946
947 #-----------------------------------------------------------------------------
948 # Blender Player
949 IF(WITH_PLAYER)
950         ADD_SUBDIRECTORY(source/blenderplayer)
951 ENDIF(WITH_PLAYER)