Fix (unreported) crash when duplicating a FileBrowser window in preview draw mode.
[blender.git] / CMakeLists.txt
index 66ee215864dab3d15b2a277ac7be85f791dd85ce..c0a0b4bd27f0132ea177614b85bf378c53cf37cd 100644 (file)
@@ -32,7 +32,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
        if(NOT DEFINED WITH_IN_SOURCE_BUILD)
                message(FATAL_ERROR
                        "CMake generation for blender is not allowed within the source directory!"
-                       "\n Remove the CMakeCache.txt file and try again from another folder, e.g.:"
+                       "\n Remove \"${CMAKE_SOURCE_DIR}/CMakeCache.txt\" and try again from another folder, e.g.:"
                        "\n "
                        "\n rm CMakeCache.txt"
                        "\n cd .."
@@ -45,7 +45,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
        endif()
 endif()
 
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.5)
 
 if(NOT EXECUTABLE_OUTPUT_PATH)
        set(FIRST_RUN TRUE)
@@ -58,7 +58,9 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules")
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/platform")
 
 # avoid having empty buildtype
-set(CMAKE_BUILD_TYPE_INIT "Release")
+if(NOT DEFINED CMAKE_BUILD_TYPE_INIT)
+       set(CMAKE_BUILD_TYPE_INIT "Release")
+endif()
 
 # quiet output for Makefiles, 'make -s' helps too
 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
@@ -193,7 +195,7 @@ endif()
 # Options
 
 # First platform specific non-cached vars
-if(UNIX AND NOT APPLE)
+if(UNIX AND NOT (APPLE OR HAIKU))
        set(WITH_X11 ON)
 endif()
 
@@ -283,11 +285,12 @@ endif()
 if(WITH_X11)
        option(WITH_X11_XINPUT    "Enable X11 Xinput (tablet support and unicode input)"  ON)
        option(WITH_X11_XF86VMODE "Enable X11 video mode switching"                       ON)
+       option(WITH_X11_XFIXES    "Enable X11 XWayland cursor warping workaround"         ON)
        option(WITH_X11_ALPHA     "Enable X11 transparent background"                     ON)
 endif()
 
 if(UNIX AND NOT APPLE)
-       option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON)
+       option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
        option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system"           ON)
 else()
        # not an option for other OS's
@@ -307,7 +310,6 @@ endif()
 # Modifiers
 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)  # this is now only available in a branch
 # mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
@@ -332,10 +334,6 @@ option(WITH_CODEC_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd
 option(WITH_ALEMBIC             "Enable Alembic Support" OFF)
 option(WITH_ALEMBIC_HDF5        "Enable Legacy Alembic Support (not officially supported)" OFF)
 
-if(APPLE)
-       option(WITH_CODEC_QUICKTIME     "Enable Quicktime Support" OFF)
-endif()
-
 # 3D format support
 # Disable opencollada when we don't have precompiled libs
 option(WITH_OPENCOLLADA   "Enable OpenCollada Support (http://www.opencollada.org)" ${_init_OPENCOLLADA})
@@ -410,12 +408,14 @@ option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
 option(WITH_CYCLES_OSL                         "Build Cycles with OSL support" ${_init_CYCLES_OSL})
 option(WITH_CYCLES_OPENSUBDIV          "Build Cycles with OpenSubdiv support" ${_init_CYCLES_OPENSUBDIV})
 option(WITH_CYCLES_CUDA_BINARIES       "Build Cycles CUDA binaries" OFF)
+option(WITH_CYCLES_CUBIN_COMPILER      "Build cubins with nvrtc based compiler instead of nvcc" OFF)
 set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 CACHE STRING "CUDA architectures to build binaries for")
 mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
 unset(PLATFORM_DEFAULT)
 option(WITH_CYCLES_LOGGING     "Build Cycles with logging support" ON)
 option(WITH_CYCLES_DEBUG       "Build Cycles with extra debug capabilities" OFF)
 option(WITH_CYCLES_NATIVE_ONLY "Build Cycles with native kernel only (which fits current CPU, use for development only)" OFF)
+mark_as_advanced(WITH_CYCLES_CUBIN_COMPILER)
 mark_as_advanced(WITH_CYCLES_LOGGING)
 mark_as_advanced(WITH_CYCLES_DEBUG)
 mark_as_advanced(WITH_CYCLES_NATIVE_ONLY)
@@ -502,7 +502,12 @@ endif()
 # Experimental support of C11 and C++11
 #
 # We default options to whatever default standard in the current compiler.
-if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11))
+if(APPLE)
+       set(_c11_init ON)
+       set(_cxx11_init ON)
+       set(WITH_C11 ON)
+       set(WITH_CXX11 ON)
+elseif(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11))
        set(_c11_init ON)
        set(_cxx11_init ON)
 else()
@@ -538,6 +543,9 @@ if(WIN32)
 
        set(WINDOWS_CODESIGN_PFX_PASSWORD CACHE STRING  "password for pfx file used for codesigning.")
        mark_as_advanced(WINDOWS_CODESIGN_PFX_PASSWORD)
+
+       option(WINDOWS_USE_VISUAL_STUDIO_FOLDERS "Organize the visual studio project according to source folders." ON)
+       mark_as_advanced(WINDOWS_USE_VISUAL_STUDIO_FOLDERS)
 endif()
 
 # avoid using again
@@ -636,13 +644,12 @@ if(NOT WITH_BOOST)
        set_and_warn(WITH_INTERNATIONAL  OFF)
        set_and_warn(WITH_OPENVDB        OFF)
        set_and_warn(WITH_OPENCOLORIO    OFF)
-       set_and_warn(WITH_MOD_BOOLEAN    OFF)
 
        set_and_warn(WITH_OPENAL         OFF)  # depends on AUDASPACE
        set_and_warn(WITH_GAMEENGINE     OFF)  # depends on AUDASPACE
        set_and_warn(WITH_PLAYER         OFF)  # depends on GAMEENGINE
 elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_AUDASPACE OR WITH_INTERNATIONAL OR
-       WITH_OPENVDB OR WITH_OPENCOLORIO OR WITH_MOD_BOOLEAN)
+       WITH_OPENVDB OR WITH_OPENCOLORIO)
        # Keep enabled
 else()
        # New dependency graph needs either Boost or C++11 for function bindings.
@@ -684,6 +691,7 @@ if(WITH_GHOST_SDL OR WITH_HEADLESS)
        set(WITH_X11           OFF)
        set(WITH_X11_XINPUT    OFF)
        set(WITH_X11_XF86VMODE OFF)
+       set(WITH_X11_XFIXES    OFF)
        set(WITH_X11_ALPHA     OFF)
        set(WITH_GHOST_XDND    OFF)
        set(WITH_INPUT_IME     OFF)
@@ -736,10 +744,6 @@ if(WITH_AUDASPACE)
        endif()
 endif()
 
-if(APPLE)
-       apple_check_quicktime()
-endif()
-
 #-----------------------------------------------------------------------------
 # Check for valid directories
 # ... a partial checkout may cause this.
@@ -759,6 +763,17 @@ if(WITH_INTERNATIONAL)
 endif()
 
 if(WITH_PYTHON)
+       # While we have this as an '#error' in 'bpy_capi_utils.h',
+       # upgrading Python tends to cause confusion for users who build.
+       # Give the error message early to make this more obvious.
+       #
+       # Do this before main 'platform_*' checks,
+       # because UNIX will search for the old Python paths which may not exist.
+       # giving errors about missing paths before this case is met.
+       if(DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.6")
+               message(FATAL_ERROR "At least Python 3.6 is required to build")
+       endif()
+
        if(NOT EXISTS "${CMAKE_SOURCE_DIR}/release/scripts/addons/modules")
                message(WARNING
                        "Addons path '${CMAKE_SOURCE_DIR}/release/scripts/addons' is missing, "
@@ -828,6 +843,14 @@ if(WITH_X11)
                endif()
        endif()
 
+       if(WITH_X11_XFIXES)
+               if(X11_Xfixes_LIB)
+                       list(APPEND PLATFORM_LINKLIBS ${X11_Xfixes_LIB})
+               else()
+                       set(WITH_X11_XFIXES OFF)
+               endif()
+       endif()
+
        if(WITH_X11_ALPHA)
                find_library(X11_Xrender_LIB Xrender  ${X11_LIB_SEARCH_PATH})
                mark_as_advanced(X11_Xrender_LIB)
@@ -1327,6 +1350,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_FORMAT_SIGN -Wformat-signedness)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_RESTRICT -Wrestrict)
 
        # gcc 4.2 gives annoying warnings on every file with this
        if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
@@ -1368,6 +1392,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_WRITE_STRINGS -Wwrite-strings)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_FORMAT_SIGN -Wformat-signedness)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_RESTRICT -Wrestrict)
 
        # gcc 4.2 gives annoying warnings on every file with this
        if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
@@ -1400,11 +1425,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
 
 elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
 
-       if(APPLE AND WITH_OPENMP) # we need the Intel omp lib linked here to not fail all tests due presence of -fopenmp !
-               set(CMAKE_REQUIRED_FLAGS "-L${LIBDIR}/openmp/lib -liomp5") # these are only used for the checks
-       endif()
-
-       # strange, clang complains these are not supported, but then yses them.
+       # strange, clang complains these are not supported, but then uses them.
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE  -Werror=return-type)
@@ -1478,6 +1499,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
                "/wd4800"  # forcing value to bool 'true' or 'false'
                # errors:
                "/we4013"  # 'function' undefined; assuming extern returning int
+               "/we4133"  # incompatible pointer types
                "/we4431"  # missing type specifier - int assumed
        )
 
@@ -1633,10 +1655,10 @@ include(build_files/cmake/packaging.cmake)
 # Use dynamic loading for OpenMP
 if(WITH_BLENDER)
        openmp_delayload(blender)
-endif(WITH_BLENDER)
+endif()
 if(WITH_PLAYER)
        openmp_delayload(blenderplayer)
-endif(WITH_PLAYER)
+endif()
 
 #-----------------------------------------------------------------------------
 # Print Final Configuration
@@ -1694,6 +1716,7 @@ if(FIRST_RUN)
        info_cfg_option(WITH_INSTALL_PORTABLE)
        info_cfg_option(WITH_X11_ALPHA)
        info_cfg_option(WITH_X11_XF86VMODE)
+       info_cfg_option(WITH_X11_XFIXES)
        info_cfg_option(WITH_X11_XINPUT)
        info_cfg_option(WITH_MEM_JEMALLOC)
        info_cfg_option(WITH_MEM_VALGRIND)
@@ -1733,7 +1756,6 @@ if(FIRST_RUN)
        endif()
 
        info_cfg_text("Modifiers:")
-       info_cfg_option(WITH_MOD_BOOLEAN)
        info_cfg_option(WITH_MOD_REMESH)
        info_cfg_option(WITH_MOD_FLUID)
        info_cfg_option(WITH_MOD_OCEANSIM)
@@ -1757,4 +1779,3 @@ endif()
 if(0)
        print_all_vars()
 endif()
-