Bevel: fix crash bug 33362, when beveling one edge at valence 2 vertex.
[blender.git] / CMakeLists.txt
index 30f61fb062b344ac58c7efcf4b5ee4fb50e1d603..0954d5ce8787b23282efe665bc56f30e02b645df 100644 (file)
@@ -190,8 +190,8 @@ option(WITH_MOD_FLUID           "Enable Elbeem Modifier (Fluid Simulation)" ON)
 option(WITH_MOD_SMOKE           "Enable Smoke Modifier (Smoke Simulation)" ON)
 option(WITH_MOD_BOOLEAN         "Enable Boolean Modifier" ON)
 option(WITH_MOD_REMESH          "Enable Remesh Modifier" ON)
-option(WITH_MOD_CLOTH_ELTOPO    "Enable Experimental cloth solver" OFF)
-mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
+# option(WITH_MOD_CLOTH_ELTOPO    "Enable Experimental cloth solver" OFF)  # this is now only available in a branch
+mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
 option(WITH_MOD_OCEANSIM        "Enable Ocean Modifier" OFF)
 
 # Image format support
@@ -234,6 +234,7 @@ option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)"
 option(WITH_RAYOPTIMIZATION    "Enable use of SIMD (SSE) optimizations for the raytracer" ON)
 if(UNIX AND NOT APPLE)
        option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
+       option(WITH_STATIC_LIBS "Try to link with static libraries, as much as possible, to make blender more portable across distributions" OFF)
 endif()
 option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
 option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder"  ON)
@@ -270,6 +271,9 @@ mark_as_advanced(WITH_ASSERT_ABORT)
 
 
 if(APPLE)
+       cmake_minimum_required(VERSION 2.8.8)
+       cmake_policy(VERSION 2.8.8)
+
        if(NOT CMAKE_OSX_ARCHITECTURES)
                set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
                "Choose the architecture you want to build Blender for: i386, x86_64 or ppc"
@@ -486,14 +490,14 @@ set(PLATFORM_LINKFLAGS_DEBUG "")
 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
 # On Unix:
 #   cmake ../blender \
-#         -D PYTHON_VERSION=3.2 \
-#         -D PYTHON_INCLUDE_DIR=/opt/py32/include/python3.2d \
-#         -D PYTHON_LIBRARY=/opt/py32/lib/libpython3.2d.so
+#         -D PYTHON_VERSION=3.3 \
+#         -D PYTHON_INCLUDE_DIR=/opt/py33/include/python3.3d \
+#         -D PYTHON_LIBRARY=/opt/py33/lib/libpython3.3d.so
 #
 # On Macs:
 #   cmake ../blender \
-#         -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2 \
-#         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config \
+#         -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3 \
+#         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/config \
 #         -G Xcode
 #
 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
@@ -502,36 +506,52 @@ set(PLATFORM_LINKFLAGS_DEBUG "")
 #Platform specifics
 
 if(UNIX AND NOT APPLE)
-       find_package(JPEG REQUIRED)
-       find_package(PNG REQUIRED)
-       find_package(ZLIB REQUIRED)
-       find_package(Freetype REQUIRED)
+       macro(find_package_wrapper)
+               STRING(TOUPPER ${ARGV0} _NAME_UPPER)
+               if(${WITH_STATIC_LIBS})
+                       set(_cmake_find_library_suffixes_back ${CMAKE_FIND_LIBRARY_SUFFIXES})
+                       set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
+               endif()
+               find_package(${ARGV})
+               if(${WITH_STATIC_LIBS})
+                       set(CMAKE_FIND_LIBRARY_SUFFIXES ${_cmake_find_library_suffixes_back})
+                       unset(_cmake_find_library_suffixes_back)
+               endif()
+       endmacro()
+
+       find_package_wrapper(JPEG REQUIRED)
+       find_package_wrapper(PNG REQUIRED)
+       find_package_wrapper(ZLIB REQUIRED)
+       find_package_wrapper(Freetype REQUIRED)
 
        if(WITH_PYTHON)
-               # No way to set py32. remove for now.
+               # No way to set py33. remove for now.
                # find_package(PythonLibs)
 
                # Use our own instead, since wothout py is such a rare case,
                # require this package
+               # XXX Linking errors with debian static python :/
+#              find_package_wrapper(PythonLibsUnix REQUIRED)
                find_package(PythonLibsUnix REQUIRED)
        endif()
 
-
        if(WITH_IMAGE_OPENEXR)
-               find_package(OpenEXR)  # our own module
+               find_package_wrapper(OpenEXR)  # our own module
                if(NOT OPENEXR_FOUND)
                        set(WITH_IMAGE_OPENEXR OFF)
                endif()
        endif()
 
        if(WITH_IMAGE_OPENJPEG)
-               find_package(OpenJPEG)
+               find_package_wrapper(OpenJPEG)
                if(NOT OPENJPEG_FOUND)
                        set(WITH_IMAGE_OPENJPEG OFF)
                endif()
        endif()
 
        if(WITH_IMAGE_TIFF)
+               # XXX Linking errors with debian static tiff :/
+#              find_package_wrapper(TIFF)
                find_package(TIFF)
                if(NOT TIFF_FOUND)
                        set(WITH_IMAGE_TIFF OFF)
@@ -540,14 +560,14 @@ if(UNIX AND NOT APPLE)
 
        # Audio IO
        if(WITH_OPENAL)
-               find_package(OpenAL)
+               find_package_wrapper(OpenAL)
                if(NOT OPENAL_FOUND)
                        set(WITH_OPENAL OFF)
                endif()
        endif()
 
        if(WITH_SDL)
-               find_package(SDL)
+               find_package_wrapper(SDL)
                mark_as_advanced(
                        SDLMAIN_LIBRARY
                        SDL_INCLUDE_DIR
@@ -561,7 +581,7 @@ if(UNIX AND NOT APPLE)
        endif()
 
        if(WITH_JACK)
-               find_package(Jack)
+               find_package_wrapper(Jack)
                if(NOT JACK_FOUND)
                        set(WITH_JACK OFF)
                endif()
@@ -569,7 +589,7 @@ if(UNIX AND NOT APPLE)
 
        # Codecs
        if(WITH_CODEC_SNDFILE)
-               find_package(SndFile)
+               find_package_wrapper(SndFile)
                if(NOT SNDFILE_FOUND)
                        set(WITH_CODEC_SNDFILE OFF)
                endif()
@@ -594,31 +614,31 @@ if(UNIX AND NOT APPLE)
        endif()
 
        if(WITH_FFTW3)
-               find_package(Fftw3)
+               find_package_wrapper(Fftw3)
                if(NOT FFTW3_FOUND)
                        set(WITH_FFTW3 OFF)
                endif()
        endif()
 
        if(WITH_OPENCOLLADA)
-               find_package(OpenCOLLADA)
+               find_package_wrapper(OpenCOLLADA)
                if(OPENCOLLADA_FOUND)
-                       find_package(XML2)
-                       find_package(PCRE)
+                       find_package_wrapper(XML2)
+                       find_package_wrapper(PCRE)
                else()
                        set(WITH_OPENCOLLADA OFF)
                endif()
        endif()
 
        if(WITH_MEM_JEMALLOC)
-               find_package(JeMalloc)
+               find_package_wrapper(JeMalloc)
                if(NOT JEMALLOC_FOUND)
                        set(WITH_MEM_JEMALLOC OFF)
                endif()
        endif()
 
        if (WITH_INPUT_NDOF)
-               find_package(Spacenav)
+               find_package_wrapper(Spacenav)
                if(NOT SPACENAV_FOUND)
                        set(WITH_INPUT_NDOF OFF)
                endif()
@@ -634,6 +654,9 @@ if(UNIX AND NOT APPLE)
                # uses in build instructions to override include and library variables
                if(NOT BOOST_CUSTOM)
                        # XXX No more lib dir, is this multithread stuff still needed?
+                       if(${WITH_STATIC_LIBS})
+                               set(Boost_USE_STATIC_LIBS ON)
+                       endif()
                        if(NOT BOOST_ROOT)
                                set(Boost_USE_MULTITHREADED OFF)
                        else()
@@ -657,7 +680,7 @@ if(UNIX AND NOT APPLE)
        endif()
 
        if(WITH_OPENIMAGEIO)
-               find_package(OpenImageIO)
+               find_package_wrapper(OpenImageIO)
 
                set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
                set(OPENIMAGEIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
@@ -677,7 +700,7 @@ if(UNIX AND NOT APPLE)
        endif()
 
        if(WITH_OPENCOLORIO)
-               find_package(OpenColorIO)
+               find_package_wrapper(OpenColorIO)
 
                set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARIES})
                set(OPENCOLORIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
@@ -696,9 +719,16 @@ if(UNIX AND NOT APPLE)
                        set(LLVM_VERSION "3.0")
                endif()
                set(LLVM_STATIC YES)
-               FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS ${LLVM_DIRECTORY})
-               if(NOT LLVM_CONFIG)
-                       FIND_PROGRAM(LLVM_CONFIG llvm-config HINTS ${LLVM_DIRECTORY})
+               if(LLVM_DIRECTORY)
+                       FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS ${LLVM_DIRECTORY}/bin NO_CMAKE_PATH)
+                       if(NOT LLVM_CONFIG)
+                               FIND_PROGRAM(LLVM_CONFIG llvm-config HINTS ${LLVM_DIRECTORY}/bin NO_CMAKE_PATH)
+                       endif()
+               else()
+                       FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION})
+                       if(NOT LLVM_CONFIG)
+                               FIND_PROGRAM(LLVM_CONFIG llvm-config)
+                       endif()
                endif()
                execute_process(COMMAND ${LLVM_CONFIG} --version
                                OUTPUT_VARIABLE LLVM_VERSION
@@ -728,10 +758,12 @@ if(UNIX AND NOT APPLE)
                                                OUTPUT_STRIP_TRAILING_WHITESPACE)
                                string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
                        endif()
-                       message(STATUS "LLVM library  = ${LLVM_LIBRARY}")
                else()
                        message(FATAL_ERROR "LLVM not found.")
                endif()
+
+               # Fix for conflict with Mesa llvmpipe
+               set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/source/creator/blender.map")
        endif()
 
        if(WITH_CYCLES_OSL)
@@ -794,7 +826,7 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
-       set(PLATFORM_LINKFLAGS "-pthread")
+       set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -pthread")
 
        # lfs on glibc, all compilers should use
        add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
@@ -842,7 +874,7 @@ elseif(WIN32)
 
                # Setup 64bit and 64bit windows systems
                if(WITH_MINGW64)
-                       message("Set 64 bit compiler for MinGW.")
+                       message("Compiling for 64 bit with MinGW-w64.")
                        set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
                endif()
        else()
@@ -898,8 +930,6 @@ elseif(WIN32)
        if(WITH_CYCLES_OSL)
                set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
        
-               message(STATUS "CYCLES_OSL = ${CYCLES_OSL}")
-       
                find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
                find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
                find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
@@ -909,9 +939,6 @@ elseif(WIN32)
        
                if(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
                        set(OSL_FOUND TRUE)
-                       message(STATUS "OSL includes = ${OSL_INCLUDES}")
-                       message(STATUS "OSL library = ${OSL_LIBRARIES}")
-                       message(STATUS "OSL compiler = ${OSL_COMPILER}")
                else()
                        message(STATUS "OSL not found")
                endif()
@@ -1072,9 +1099,17 @@ elseif(WIN32)
 
                if(WITH_PYTHON)
                        # normally cached but not since we include them with blender
-                       set(PYTHON_VERSION 3.2) # CACHE STRING)
+                       if(MSVC10)
+                               set(PYTHON_VERSION 3.2) # CACHE STRING)
+                       else()
+                               set(PYTHON_VERSION 3.3) # CACHE STRING)
+                       endif()
+
                        set_lib_path(PYTHON "python")
-                       set(PYTHON_LIBRARY ${PYTHON}/lib/python32.lib) #CACHE FILEPATH
+                       STRING(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
+                       set(PYTHON_LIBRARY ${PYTHON}/lib/python${_PYTHON_VERSION_NO_DOTS}.lib) #CACHE FILEPATH
+                       unset(_PYTHON_VERSION_NO_DOTS)
+
                        #Shared includes for both vc2008 and vc2010
                        set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/include/python${PYTHON_VERSION})
 
@@ -1182,7 +1217,7 @@ elseif(WIN32)
                #comes with own pthread library
                if(NOT WITH_MINGW64)
                        set(PTHREADS ${LIBDIR}/pthreads)
-                       set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
+                       #set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
                        set(PTHREADS_LIBPATH ${PTHREADS}/lib)
                        set(PTHREADS_LIBRARIES pthreadGC2)
                endif()
@@ -1254,9 +1289,9 @@ elseif(WIN32)
 
                if(WITH_PYTHON)
                        # normally cached but not since we include them with blender
-                       set(PYTHON_VERSION 3.2) #  CACHE STRING)
+                       set(PYTHON_VERSION 3.3) #  CACHE STRING)
                        set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")  # CACHE PATH)
-                       set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32mw.lib")  # CACHE FILEPATH)
+                       set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python33mw.lib")  # CACHE FILEPATH)
 
                        # uncached vars
                        set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
@@ -1575,9 +1610,6 @@ elseif(APPLE)
                find_library(LLVM_LIBRARY
                             NAMES LLVMAnalysis # first of a whole bunch of libs to get
                             PATHS ${LLVM_LIB_DIR})
-               message(STATUS "LLVM version  = ${LLVM_VERSION}")
-               message(STATUS "LLVM dir      = ${LLVM_DIRECTORY}")
-               message(STATUS "LLVM lib dir  = ${LLVM_LIB_DIR}")
 
                if(LLVM_LIBRARY AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
                        if(LLVM_STATIC)
@@ -1589,7 +1621,6 @@ elseif(APPLE)
                                                OUTPUT_STRIP_TRAILING_WHITESPACE)
                                string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
                        endif()
-                       message(STATUS "LLVM library  = ${LLVM_LIBRARY}")
                else()
                        message(FATAL_ERROR "LLVM not found.")
                endif()
@@ -1598,8 +1629,6 @@ elseif(APPLE)
        if(WITH_CYCLES_OSL)
                set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
        
-               message(STATUS "CYCLES_OSL = ${CYCLES_OSL}")
-       
                find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
                find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
                find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
@@ -1610,9 +1639,6 @@ elseif(APPLE)
        
                if(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
                        set(OSL_FOUND TRUE)
-                       message(STATUS "OSL includes = ${OSL_INCLUDES}")
-                       message(STATUS "OSL library = ${OSL_LIBRARIES}")
-                       message(STATUS "OSL compiler = ${OSL_COMPILER}")
                else()
                        message(STATUS "OSL not found")
                endif()