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