- add_compile_options(-Wno-invalid-offsetof)
- # The following warning indicates that an attribute __attribute__((__ms_struct__)) was applied
- # to a struct or a class that has virtual members or a base class. In that case, clang
- # may not generate the same object layout as MSVC.
- add_compile_options(-Wno-incompatible-ms-struct)
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-invalid-offsetof>)
+
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ # The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop
+ # after hitting just about 20 errors.
+ add_compile_options(-ferror-limit=4096)
+
+ # Disabled warnings
+ add_compile_options(-Wno-unused-private-field)
+ # Explicit constructor calls are not supported by clang (this->ClassName::ClassName())
+ add_compile_options(-Wno-microsoft)
+ # This warning is caused by comparing 'this' to NULL
+ add_compile_options(-Wno-tautological-compare)
+ # There are constants of type BOOL used in a condition. But BOOL is defined as int
+ # and so the compiler thinks that there is a mistake.
+ add_compile_options(-Wno-constant-logical-operand)
+ # We use pshpack1/2/4/8.h and poppack.h headers to set and restore packing. However
+ # clang 6.0 complains when the packing change lifetime is not contained within
+ # a header file.
+ add_compile_options(-Wno-pragma-pack)
+
+ add_compile_options(-Wno-unknown-warning-option)
+
+ # The following warning indicates that an attribute __attribute__((__ms_struct__)) was applied
+ # to a struct or a class that has virtual members or a base class. In that case, clang
+ # may not generate the same object layout as MSVC.
+ add_compile_options(-Wno-incompatible-ms-struct)
+ # Do not convert a #warning into an #error
+ add_compile_options("-Wno-error=#warnings")
+ else()
+ add_compile_options(-Wno-unused-variable)
+ add_compile_options(-Wno-unused-but-set-variable)
+ add_compile_options(-fms-extensions)
+ add_compile_options(-Wno-unknown-pragmas)
+ # Do not convert a #warning into an #error
+ add_compile_options(-Wno-error=cpp)
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
+ add_compile_options(-Wno-nonnull-compare)
+ endif()
+ if (COMPILER_SUPPORTS_F_ALIGNED_NEW)
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-faligned-new>)
+ endif()
+ endif()