Skip to content

Commit f7d956e

Browse files
authored
Merge pull request opencv#7869 from alalek:icc
Build with ICC
2 parents a8c7a10 + 737fa51 commit f7d956e

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

cmake/OpenCVCompilerOptions.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ if(MINGW)
101101
endif()
102102
endif()
103103

104+
if(CV_ICC AND NOT ENABLE_FAST_MATH)
105+
add_extra_compiler_option("-fp-model precise")
106+
endif()
107+
104108
if(CMAKE_COMPILER_IS_GNUCXX)
105109
# High level of warnings.
106110
add_extra_compiler_option(-W)
@@ -432,6 +436,13 @@ if(MSVC)
432436
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4275) # non dll-interface class 'std::exception' used as base for dll-interface class 'cv::Exception'
433437
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4589) # Constructor of abstract class 'cv::ORB' ignores initializer for virtual base class 'cv::Algorithm'
434438
endif()
439+
440+
if(CV_ICC AND NOT ENABLE_NOISY_WARNINGS)
441+
foreach(flags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG)
442+
string(REGEX REPLACE "( |^)/W[0-9]+( |$)" "\\1\\2" ${flags} "${${flags}}")
443+
endforeach()
444+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qwd673") # PCH warning
445+
endif()
435446
endif()
436447

437448
if(APPLE AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{LDFLAGS} AND EXISTS "/usr/local/lib")

cmake/OpenCVUtils.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,16 @@ macro(ocv_warnings_disable)
302302
set(_flag_vars "")
303303
set(_msvc_warnings "")
304304
set(_gxx_warnings "")
305+
set(_icc_warnings "")
305306
foreach(arg ${ARGN})
306307
if(arg MATCHES "^CMAKE_")
307308
list(APPEND _flag_vars ${arg})
308309
elseif(arg MATCHES "^/wd")
309310
list(APPEND _msvc_warnings ${arg})
310311
elseif(arg MATCHES "^-W")
311312
list(APPEND _gxx_warnings ${arg})
313+
elseif(arg MATCHES "^-wd" OR arg MATCHES "^-Qwd" OR arg MATCHES "^/Qwd")
314+
list(APPEND _icc_warnings ${arg})
312315
endif()
313316
endforeach()
314317
if(MSVC AND _msvc_warnings AND _flag_vars)
@@ -331,9 +334,25 @@ macro(ocv_warnings_disable)
331334
endforeach()
332335
endforeach()
333336
endif()
337+
if(CV_ICC AND _icc_warnings AND _flag_vars)
338+
foreach(var ${_flag_vars})
339+
foreach(warning ${_icc_warnings})
340+
if(UNIX)
341+
string(REPLACE "-Qwd" "-wd" warning "${warning}")
342+
else()
343+
string(REPLACE "-wd" "-Qwd" warning "${warning}")
344+
endif()
345+
ocv_check_flag_support(${var} "${warning}" _varname)
346+
if(${_varname})
347+
set(${var} "${${var}} ${warning}")
348+
endif()
349+
endforeach()
350+
endforeach()
351+
endif()
334352
unset(_flag_vars)
335353
unset(_msvc_warnings)
336354
unset(_gxx_warnings)
355+
unset(_icc_warnings)
337356
endif(NOT ENABLE_NOISY_WARNINGS)
338357
endmacro()
339358

modules/core/test/test_arithm.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#include "test_precomp.hpp"
22
#include <cmath>
3-
#ifndef NAN
4-
#include <limits> // numeric_limits<T>::quiet_NaN()
5-
#define NAN std::numeric_limits<float>::quiet_NaN()
6-
#endif
73

84
using namespace cv;
95
using namespace std;
@@ -1895,7 +1891,7 @@ TEST(MinMaxLoc, regression_4955_nans)
18951891
cv::Mat one_mat(2, 2, CV_32F, cv::Scalar(1));
18961892
cv::minMaxLoc(one_mat, NULL, NULL, NULL, NULL);
18971893

1898-
cv::Mat nan_mat(2, 2, CV_32F, cv::Scalar(NAN));
1894+
cv::Mat nan_mat(2, 2, CV_32F, cv::Scalar(std::numeric_limits<float>::quiet_NaN()));
18991895
cv::minMaxLoc(nan_mat, NULL, NULL, NULL, NULL);
19001896
}
19011897

modules/objdetect/test/test_cascadeandhog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ void HOGDescriptorTester::detect(const Mat& img,
10871087
}
10881088

10891089
const double eps = FLT_EPSILON * 100;
1090-
double diff_norm = cvtest::norm(actual_weights, weights, NORM_L2);
1090+
double diff_norm = cvtest::norm(actual_weights, weights, NORM_L2 + NORM_RELATIVE);
10911091
if (diff_norm > eps)
10921092
{
10931093
ts->printf(cvtest::TS::SUMMARY, "Weights for found locations aren't equal.\n"
@@ -1167,7 +1167,7 @@ void HOGDescriptorTester::compute(InputArray _img, vector<float>& descriptors,
11671167
std::vector<float> actual_descriptors;
11681168
actual_hog->compute(img, actual_descriptors, winStride, padding, locations);
11691169

1170-
double diff_norm = cvtest::norm(actual_descriptors, descriptors, NORM_L2);
1170+
double diff_norm = cvtest::norm(actual_descriptors, descriptors, NORM_L2 + NORM_RELATIVE);
11711171
const double eps = FLT_EPSILON * 100;
11721172
if (diff_norm > eps)
11731173
{
@@ -1316,7 +1316,7 @@ void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle
13161316
const double eps = FLT_EPSILON * 100;
13171317
for (i = 0; i < 2; ++i)
13181318
{
1319-
double diff_norm = cvtest::norm(reference_mats[i], actual_mats[i], NORM_L2);
1319+
double diff_norm = cvtest::norm(actual_mats[i], reference_mats[i], NORM_L2 + NORM_RELATIVE);
13201320
if (diff_norm > eps)
13211321
{
13221322
ts->printf(cvtest::TS::LOG, "%s matrices are not equal\n"

0 commit comments

Comments
 (0)