Changeset View
Changeset View
Standalone View
Standalone View
CMakeLists.txt
| Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | |||||
| project(Blender) | project(Blender) | ||||
| blender_project_hack_post() | blender_project_hack_post() | ||||
| enable_testing() | enable_testing() | ||||
| # ----------------------------------------------------------------------------- | # ----------------------------------------------------------------------------- | ||||
| # Test Compiler Support | |||||
| # | |||||
| # Keep in sync with: https://wiki.blender.org/wiki/Building_Blender | |||||
| if(CMAKE_COMPILER_IS_GNUCC) | |||||
| if(CMAKE_COMPILER_IS_GNUCC AND ("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "9.3.1")) | |||||
| message(FATAL_ERROR "The minimum supported version of GCC is 9.3.1") | |||||
| endif() | |||||
| elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") | |||||
| if(CMAKE_COMPILER_IS_GNUCC AND ("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "8.0")) | |||||
| message(FATAL_ERROR "The minimum supported version of CLANG is 8.0") | |||||
| endif() | |||||
| elseif(CMAKE_CXX_COMPILER_ID MATCHES MSVC) | |||||
| if(MSVC_VERSION VERSION_LESS "1928") | |||||
| message(FATAL_ERROR "The minimum supported version of MSVC is 2019 (16.9.16)") | |||||
| endif() | |||||
| endif() | |||||
| # ----------------------------------------------------------------------------- | |||||
| # Test Compiler/Library Features | # Test Compiler/Library Features | ||||
| include(build_files/cmake/have_features.cmake) | include(build_files/cmake/have_features.cmake) | ||||
| # ----------------------------------------------------------------------------- | # ----------------------------------------------------------------------------- | ||||
| # Redirect Output Files | # Redirect Output Files | ||||
| ▲ Show 20 Lines • Show All 1,300 Lines • ▼ Show 20 Lines | if(CMAKE_COMPILER_IS_GNUCC) | ||||
| add_check_c_compiler_flag(C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits) | 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_FORMAT_SIGN -Wformat-signedness) | ||||
| add_check_c_compiler_flag(C_WARNINGS C_WARN_RESTRICT -Wrestrict) | add_check_c_compiler_flag(C_WARNINGS C_WARN_RESTRICT -Wrestrict) | ||||
| # C-only. | # C-only. | ||||
| add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_NULL -Wnonnull) | add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_NULL -Wnonnull) | ||||
| add_check_c_compiler_flag(C_WARNINGS C_WARN_ABSOLUTE_VALUE -Wabsolute-value) | add_check_c_compiler_flag(C_WARNINGS C_WARN_ABSOLUTE_VALUE -Wabsolute-value) | ||||
| # gcc 4.2 gives annoying warnings on every file with this | |||||
| if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3") | |||||
| add_check_c_compiler_flag(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized) | add_check_c_compiler_flag(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized) | ||||
| endif() | |||||
| # versions before gcc4.6 give many BLI_math warnings | |||||
| if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.6") | |||||
| add_check_c_compiler_flag(C_WARNINGS C_WARN_REDUNDANT_DECLS -Wredundant-decls) | add_check_c_compiler_flag(C_WARNINGS C_WARN_REDUNDANT_DECLS -Wredundant-decls) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls) | ||||
| endif() | |||||
| # versions before gcc4.8 include global name-space. | |||||
| if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.8") | |||||
| add_check_c_compiler_flag(C_WARNINGS C_WARN_SHADOW -Wshadow) | add_check_c_compiler_flag(C_WARNINGS C_WARN_SHADOW -Wshadow) | ||||
| endif() | |||||
| # disable because it gives warnings for printf() & friends. | # disable because it gives warnings for printf() & friends. | ||||
| # add_check_c_compiler_flag(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion) | # add_check_c_compiler_flag(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion) | ||||
| if(NOT APPLE) | if(NOT APPLE) | ||||
| add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable) | add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable) | ||||
| endif() | endif() | ||||
| Show All 10 Lines | if(CMAKE_COMPILER_IS_GNUCC) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_POINTER_ARITH -Wpointer-arith) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_POINTER_ARITH -Wpointer-arith) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNUSED_PARAMETER -Wunused-parameter) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNUSED_PARAMETER -Wunused-parameter) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_WRITE_STRINGS -Wwrite-strings) | 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_UNDEF -Wundef) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_FORMAT_SIGN -Wformat-signedness) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_FORMAT_SIGN -Wformat-signedness) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_RESTRICT -Wrestrict) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_RESTRICT -Wrestrict) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override) | ||||
| # gcc 4.2 gives annoying warnings on every file with this | |||||
| if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3") | |||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized) | ||||
| endif() | |||||
| # causes too many warnings | # causes too many warnings | ||||
| if(NOT APPLE) | if(NOT APPLE) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNDEF -Wundef) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNDEF -Wundef) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations) | ||||
| endif() | endif() | ||||
| # Use 'ATTR_FALLTHROUGH' macro to suppress. | # Use 'ATTR_FALLTHROUGH' macro to suppress. | ||||
| if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0")) | |||||
| add_check_c_compiler_flag(C_WARNINGS C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5) | add_check_c_compiler_flag(C_WARNINGS C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5) | ||||
| add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5) | add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5) | ||||
| endif() | |||||
| # --------------------- | # --------------------- | ||||
| # Suppress Strict Flags | # Suppress Strict Flags | ||||
| # | # | ||||
| # Exclude the following warnings from this list: | # Exclude the following warnings from this list: | ||||
| # - `-Wno-address`: | # - `-Wno-address`: | ||||
| # This can give useful hints that point to bugs/misleading logic. | # This can give useful hints that point to bugs/misleading logic. | ||||
| # - `-Wno-strict-prototypes`: | # - `-Wno-strict-prototypes`: | ||||
| Show All 13 Lines | if(CMAKE_COMPILER_IS_GNUCC) | ||||
| add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized) | add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized) | ||||
| add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CLASS_MEMACCESS -Wno-class-memaccess) | add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CLASS_MEMACCESS -Wno-class-memaccess) | ||||
| add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_COMMENT -Wno-comment) | add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_COMMENT -Wno-comment) | ||||
| add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs) | add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs) | ||||
| add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable) | add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable) | ||||
| add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized) | add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized) | ||||
| if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0")) | |||||
| add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough) | add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough) | ||||
| endif() | |||||
| if(NOT APPLE) | if(NOT APPLE) | ||||
| add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable) | add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable) | ||||
| endif() | endif() | ||||
| elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") | elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") | ||||
| # strange, clang complains these are not supported, but then uses them. | # strange, clang complains these are not supported, but then uses them. | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
| elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") | elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") | ||||
| # most msvc warnings are C & C++ | # most msvc warnings are C & C++ | ||||
| set(_WARNINGS | set(_WARNINGS | ||||
| # warning level: | # warning level: | ||||
| "/W3" | "/W3" | ||||
| "/w34062" # switch statement contains 'default' but no 'case' labels | "/w34062" # switch statement contains 'default' but no 'case' labels | ||||
| "/w34115" # 'type' : named type definition in parentheses | "/w34115" # 'type' : named type definition in parentheses | ||||
| "/w34189" # local variable is initialized but not referenced | "/w34189" # local variable is initialized but not referenced | ||||
| # see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=vs-2017 | |||||
| "/w35038" # order of initialization in c++ constructors | |||||
| # disable: | # disable: | ||||
| "/wd4018" # signed/unsigned mismatch | "/wd4018" # signed/unsigned mismatch | ||||
| "/wd4146" # unary minus operator applied to unsigned type, result still unsigned | "/wd4146" # unary minus operator applied to unsigned type, result still unsigned | ||||
| "/wd4065" # switch statement contains 'default' but no 'case' labels | "/wd4065" # switch statement contains 'default' but no 'case' labels | ||||
| "/wd4127" # conditional expression is constant | "/wd4127" # conditional expression is constant | ||||
| "/wd4181" # qualifier applied to reference type; ignored | "/wd4181" # qualifier applied to reference type; ignored | ||||
| "/wd4200" # zero-sized array in struct/union | "/wd4200" # zero-sized array in struct/union | ||||
| "/wd4244" # conversion from 'type1' to 'type2', possible loss of data | "/wd4244" # conversion from 'type1' to 'type2', possible loss of data | ||||
| "/wd4267" # conversion from 'size_t' to 'type', possible loss of data | "/wd4267" # conversion from 'size_t' to 'type', possible loss of data | ||||
| "/wd4305" # truncation from 'type1' to 'type2' | "/wd4305" # truncation from 'type1' to 'type2' | ||||
| "/wd4800" # forcing value to bool 'true' or 'false' | "/wd4800" # forcing value to bool 'true' or 'false' | ||||
| "/wd4828" # The file contains a character that is illegal | "/wd4828" # The file contains a character that is illegal | ||||
| "/wd4996" # identifier was declared deprecated | "/wd4996" # identifier was declared deprecated | ||||
| "/wd4661" # no suitable definition provided for explicit template instantiation request | "/wd4661" # no suitable definition provided for explicit template instantiation request | ||||
| "/wd4848" # 'no_unique_address' is a vendor extension in C++17 | "/wd4848" # 'no_unique_address' is a vendor extension in C++17 | ||||
| # errors: | # errors: | ||||
| "/we4013" # 'function' undefined; assuming extern returning int | "/we4013" # 'function' undefined; assuming extern returning int | ||||
| "/we4133" # incompatible pointer types | "/we4133" # incompatible pointer types | ||||
| "/we4431" # missing type specifier - int assumed | "/we4431" # missing type specifier - int assumed | ||||
| ) | ) | ||||
| if(MSVC_VERSION GREATER_EQUAL 1911) | |||||
| # see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=vs-2017 | |||||
| string(APPEND _WARNINGS " /w35038") # order of initialization in c++ constructors | |||||
| endif() | |||||
| string(REPLACE ";" " " _WARNINGS "${_WARNINGS}") | string(REPLACE ";" " " _WARNINGS "${_WARNINGS}") | ||||
| set(C_WARNINGS "${_WARNINGS}") | set(C_WARNINGS "${_WARNINGS}") | ||||
| set(CXX_WARNINGS "${_WARNINGS}") | set(CXX_WARNINGS "${_WARNINGS}") | ||||
| unset(_WARNINGS) | unset(_WARNINGS) | ||||
| endif() | endif() | ||||
| # ensure python header is found since detection can fail, this could happen | # ensure python header is found since detection can fail, this could happen | ||||
| # with _any_ library but since we used a fixed python version this tends to | # with _any_ library but since we used a fixed python version this tends to | ||||
| Show All 35 Lines | |||||
| # If C++17 is not available, downgrading to an earlier standard is NOT OK. | # If C++17 is not available, downgrading to an earlier standard is NOT OK. | ||||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||||
| # Do not enable compiler specific language extensions. | # Do not enable compiler specific language extensions. | ||||
| set(CMAKE_CXX_EXTENSIONS OFF) | set(CMAKE_CXX_EXTENSIONS OFF) | ||||
| # Make MSVC properly report the value of the __cplusplus preprocessor macro | # Make MSVC properly report the value of the __cplusplus preprocessor macro | ||||
| # Available MSVC 15.7 (1914) and up, without this it reports 199711L regardless | # Available MSVC 15.7 (1914) and up, without this it reports 199711L regardless | ||||
| # of the C++ standard chosen above. | # of the C++ standard chosen above. | ||||
| if(MSVC AND MSVC_VERSION GREATER 1913) | if(MSVC) | ||||
| string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus") | string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus") | ||||
| endif() | endif() | ||||
| # Visual Studio has all standards it supports available by default | # Visual Studio has all standards it supports available by default | ||||
| # Clang on windows copies this behavior and does not support these switches | # Clang on windows copies this behavior and does not support these switches | ||||
| if( | if( | ||||
| CMAKE_COMPILER_IS_GNUCC OR | CMAKE_COMPILER_IS_GNUCC OR | ||||
| (CMAKE_C_COMPILER_ID MATCHES "Clang" AND (NOT MSVC)) OR | (CMAKE_C_COMPILER_ID MATCHES "Clang" AND (NOT MSVC)) OR | ||||
| ▲ Show 20 Lines • Show All 274 Lines • Show Last 20 Lines | |||||