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