diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index c433d988fd..0c638c482d 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -101,6 +101,10 @@ if(MINGW) endif() endif() +if(CV_ICC AND NOT ENABLE_FAST_MATH) + add_extra_compiler_option("-fp-model precise") +endif() + if(CMAKE_COMPILER_IS_GNUCXX) # High level of warnings. add_extra_compiler_option(-W) @@ -432,6 +436,13 @@ if(MSVC) ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4275) # non dll-interface class 'std::exception' used as base for dll-interface class 'cv::Exception' ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4589) # Constructor of abstract class 'cv::ORB' ignores initializer for virtual base class 'cv::Algorithm' endif() + + if(CV_ICC AND NOT ENABLE_NOISY_WARNINGS) + foreach(flags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG) + string(REGEX REPLACE "( |^)/W[0-9]+( |$)" "\\1\\2" ${flags} "${${flags}}") + endforeach() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qwd673") # PCH warning + endif() endif() if(APPLE AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{LDFLAGS} AND EXISTS "/usr/local/lib") diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index 1d779d6775..9bde08e85e 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -302,6 +302,7 @@ macro(ocv_warnings_disable) set(_flag_vars "") set(_msvc_warnings "") set(_gxx_warnings "") + set(_icc_warnings "") foreach(arg ${ARGN}) if(arg MATCHES "^CMAKE_") list(APPEND _flag_vars ${arg}) @@ -309,6 +310,8 @@ macro(ocv_warnings_disable) list(APPEND _msvc_warnings ${arg}) elseif(arg MATCHES "^-W") list(APPEND _gxx_warnings ${arg}) + elseif(arg MATCHES "^-wd" OR arg MATCHES "^-Qwd" OR arg MATCHES "^/Qwd") + list(APPEND _icc_warnings ${arg}) endif() endforeach() if(MSVC AND _msvc_warnings AND _flag_vars) @@ -331,9 +334,25 @@ macro(ocv_warnings_disable) endforeach() endforeach() endif() + if(CV_ICC AND _icc_warnings AND _flag_vars) + foreach(var ${_flag_vars}) + foreach(warning ${_icc_warnings}) + if(UNIX) + string(REPLACE "-Qwd" "-wd" warning "${warning}") + else() + string(REPLACE "-wd" "-Qwd" warning "${warning}") + endif() + ocv_check_flag_support(${var} "${warning}" _varname) + if(${_varname}) + set(${var} "${${var}} ${warning}") + endif() + endforeach() + endforeach() + endif() unset(_flag_vars) unset(_msvc_warnings) unset(_gxx_warnings) + unset(_icc_warnings) endif(NOT ENABLE_NOISY_WARNINGS) endmacro() diff --git a/modules/core/test/test_arithm.cpp b/modules/core/test/test_arithm.cpp index 0781fd1a3f..a23cee91dd 100644 --- a/modules/core/test/test_arithm.cpp +++ b/modules/core/test/test_arithm.cpp @@ -1,9 +1,5 @@ #include "test_precomp.hpp" #include -#ifndef NAN -#include // numeric_limits::quiet_NaN() -#define NAN std::numeric_limits::quiet_NaN() -#endif using namespace cv; using namespace std; @@ -1895,7 +1891,7 @@ TEST(MinMaxLoc, regression_4955_nans) cv::Mat one_mat(2, 2, CV_32F, cv::Scalar(1)); cv::minMaxLoc(one_mat, NULL, NULL, NULL, NULL); - cv::Mat nan_mat(2, 2, CV_32F, cv::Scalar(NAN)); + cv::Mat nan_mat(2, 2, CV_32F, cv::Scalar(std::numeric_limits::quiet_NaN())); cv::minMaxLoc(nan_mat, NULL, NULL, NULL, NULL); } diff --git a/modules/objdetect/test/test_cascadeandhog.cpp b/modules/objdetect/test/test_cascadeandhog.cpp index 1c844da88b..806ce1f231 100644 --- a/modules/objdetect/test/test_cascadeandhog.cpp +++ b/modules/objdetect/test/test_cascadeandhog.cpp @@ -1087,7 +1087,7 @@ void HOGDescriptorTester::detect(const Mat& img, } const double eps = FLT_EPSILON * 100; - double diff_norm = cvtest::norm(actual_weights, weights, NORM_L2); + double diff_norm = cvtest::norm(actual_weights, weights, NORM_L2 + NORM_RELATIVE); if (diff_norm > eps) { ts->printf(cvtest::TS::SUMMARY, "Weights for found locations aren't equal.\n" @@ -1167,7 +1167,7 @@ void HOGDescriptorTester::compute(InputArray _img, vector& descriptors, std::vector actual_descriptors; actual_hog->compute(img, actual_descriptors, winStride, padding, locations); - double diff_norm = cvtest::norm(actual_descriptors, descriptors, NORM_L2); + double diff_norm = cvtest::norm(actual_descriptors, descriptors, NORM_L2 + NORM_RELATIVE); const double eps = FLT_EPSILON * 100; if (diff_norm > eps) { @@ -1316,7 +1316,7 @@ void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle const double eps = FLT_EPSILON * 100; for (i = 0; i < 2; ++i) { - double diff_norm = cvtest::norm(reference_mats[i], actual_mats[i], NORM_L2); + double diff_norm = cvtest::norm(actual_mats[i], reference_mats[i], NORM_L2 + NORM_RELATIVE); if (diff_norm > eps) { ts->printf(cvtest::TS::LOG, "%s matrices are not equal\n"