Skip to content

Commit 4acda3f

Browse files
committed
Merge pull request opencv#7428 from alalek:cmake_fix_compiler_flags_detection
2 parents 994815f + 714db4c commit 4acda3f

File tree

20 files changed

+66
-38
lines changed

20 files changed

+66
-38
lines changed

apps/traincascade/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ endif()
88
project(traincascade)
99
set(the_target opencv_traincascade)
1010

11+
ocv_warnings_disable(CMAKE_CXX_FLAGS -Woverloaded-virtual)
12+
1113
ocv_target_include_directories(${the_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
1214
ocv_target_include_modules_recurse(${the_target} ${OPENCV_TRAINCASCADE_DEPS})
1315

cmake/OpenCVUtils.cmake

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ set(OCV_COMPILER_FAIL_REGEX
199199
"[Uu]nknown option" # HP
200200
"[Ww]arning: [Oo]ption" # SunPro
201201
"command option .* is not recognized" # XL
202-
"not supported in this configuration; ignored" # AIX
202+
"not supported in this configuration, ignored" # AIX (';' is replaced with ',')
203203
"File with unknown suffix passed to linker" # PGI
204204
"WARNING: unknown flag:" # Open64
205205
)
@@ -238,19 +238,39 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
238238
COMPILE_DEFINITIONS "${FLAG}"
239239
OUTPUT_VARIABLE OUTPUT)
240240

241-
FOREACH(_regex ${OCV_COMPILER_FAIL_REGEX})
242-
IF("${OUTPUT}" MATCHES "${_regex}")
243-
SET(${RESULT} 0)
244-
break()
245-
ENDIF()
246-
ENDFOREACH()
241+
if(${RESULT})
242+
string(REPLACE ";" "," OUTPUT_LINES "${OUTPUT}")
243+
string(REPLACE "\n" ";" OUTPUT_LINES "${OUTPUT_LINES}")
244+
foreach(_regex ${OCV_COMPILER_FAIL_REGEX})
245+
if(NOT ${RESULT})
246+
break()
247+
endif()
248+
foreach(_line ${OUTPUT_LINES})
249+
if("${_line}" MATCHES "${_regex}")
250+
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
251+
"Build output check failed:\n"
252+
" Regex: '${_regex}'\n"
253+
" Output line: '${_line}'\n")
254+
set(${RESULT} 0)
255+
break()
256+
endif()
257+
endforeach()
258+
endforeach()
259+
endif()
247260

248261
IF(${RESULT})
249262
SET(${RESULT} 1 CACHE INTERNAL "Test ${RESULT}")
250263
MESSAGE(STATUS "Performing Test ${RESULT} - Success")
251264
ELSE(${RESULT})
252265
MESSAGE(STATUS "Performing Test ${RESULT} - Failed")
253266
SET(${RESULT} "" CACHE INTERNAL "Test ${RESULT}")
267+
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
268+
"Compilation failed:\n"
269+
" source file: '${_fname}'\n"
270+
" check option: '${FLAG}'\n"
271+
"===== BUILD LOG =====\n"
272+
"${OUTPUT}\n"
273+
"===== END =====\n\n")
254274
ENDIF(${RESULT})
255275
else()
256276
SET(${RESULT} 0)

modules/core/test/ocl/test_arithm.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ PARAM_TEST_CASE(ArithmTestBase, MatDepth, Channels, bool)
134134
use_roi = GET_PARAM(2);
135135
}
136136

137-
virtual void generateTestData(bool with_val_in_range = false)
137+
void generateTestData(bool with_val_in_range = false)
138138
{
139139
const int type = CV_MAKE_TYPE(depth, cn);
140140

@@ -897,7 +897,7 @@ struct RepeatTestCase :
897897
{
898898
int nx, ny;
899899

900-
virtual void generateTestData()
900+
void generateTestData()
901901
{
902902
const int type = CV_MAKE_TYPE(depth, cn);
903903

@@ -1495,7 +1495,7 @@ PARAM_TEST_CASE(InRange, MatDepth, Channels, bool /*Scalar or not*/, bool /*Roi*
14951495
use_roi = GET_PARAM(3);
14961496
}
14971497

1498-
virtual void generateTestData()
1498+
void generateTestData()
14991499
{
15001500
const int type = CV_MAKE_TYPE(depth, cn);
15011501

@@ -1574,7 +1574,7 @@ PARAM_TEST_CASE(ConvertScaleAbs, MatDepth, Channels, bool)
15741574
use_roi = GET_PARAM(2);
15751575
}
15761576

1577-
virtual void generateTestData()
1577+
void generateTestData()
15781578
{
15791579
const int stype = CV_MAKE_TYPE(depth, cn);
15801580
const int dtype = CV_MAKE_TYPE(CV_8U, cn);
@@ -1647,7 +1647,7 @@ PARAM_TEST_CASE(PatchNaNs, Channels, bool)
16471647
use_roi = GET_PARAM(1);
16481648
}
16491649

1650-
virtual void generateTestData()
1650+
void generateTestData()
16511651
{
16521652
const int type = CV_MAKE_TYPE(CV_32F, cn);
16531653

@@ -1727,7 +1727,7 @@ PARAM_TEST_CASE(Reduce, std::pair<MatDepth, MatDepth>, Channels, int, bool)
17271727
use_roi = GET_PARAM(3);
17281728
}
17291729

1730-
virtual void generateTestData()
1730+
void generateTestData()
17311731
{
17321732
const int stype = CV_MAKE_TYPE(sdepth, cn);
17331733
dtype = CV_MAKE_TYPE(ddepth, cn);

modules/core/test/ocl/test_matrix_operation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ PARAM_TEST_CASE(ConvertTo, MatDepth, MatDepth, Channels, bool)
7171
use_roi = GET_PARAM(3);
7272
}
7373

74-
virtual void generateTestData()
74+
void generateTestData()
7575
{
7676
Size roiSize = randomSize(1, MAX_VALUE);
7777
Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);

modules/core/test/test_ippasync.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ PARAM_TEST_CASE(IPPAsync, MatDepth, Channels, hppAccelType)
3232
accelType = GET_PARAM(2);
3333
}
3434

35-
virtual void generateTestData()
35+
void generateTestData()
3636
{
3737
Size matrix_Size = randomSize(2, 100);
3838
const double upValue = 100;
@@ -102,7 +102,7 @@ PARAM_TEST_CASE(IPPAsyncShared, Channels, hppAccelType)
102102
type=CV_MAKE_TYPE(CV_8U, GET_PARAM(0));
103103
}
104104

105-
virtual void generateTestData()
105+
void generateTestData()
106106
{
107107
Size matrix_Size = randomSize(2, 100);
108108
hpp32u pitch, size;

modules/imgproc/test/ocl/test_histogram.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ PARAM_TEST_CASE(CalcBackProject, MatDepth, int, bool)
9494
uimages_roi.resize(N);
9595
}
9696

97-
virtual void random_roi()
97+
void random_roi()
9898
{
9999
Size roiSize = randomSize(1, MAX_VALUE);
100100

@@ -233,7 +233,7 @@ PARAM_TEST_CASE(CalcHist, bool)
233233
useRoi = GET_PARAM(0);
234234
}
235235

236-
virtual void random_roi()
236+
void random_roi()
237237
{
238238
Size roiSize = randomSize(1, MAX_VALUE);
239239

modules/imgproc/test/ocl/test_houghlines.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ PARAM_TEST_CASE(HoughLines, double, double, int)
4040
threshold = GET_PARAM(2);
4141
}
4242

43-
virtual void generateTestData()
43+
void generateTestData()
4444
{
4545
src_size = randomSize(500, 1920);
4646
src.create(src_size, CV_8UC1);
@@ -55,15 +55,15 @@ PARAM_TEST_CASE(HoughLines, double, double, int)
5555
src.copyTo(usrc);
5656
}
5757

58-
virtual void readRealTestData()
58+
void readRealTestData()
5959
{
6060
Mat img = readImage("shared/pic5.png", IMREAD_GRAYSCALE);
6161
Canny(img, src, 100, 150, 3);
6262

6363
src.copyTo(usrc);
6464
}
6565

66-
virtual void Near(double eps = 0.)
66+
void Near(double eps = 0.)
6767
{
6868
EXPECT_EQ(dst.size(), udst.size());
6969

@@ -124,15 +124,15 @@ PARAM_TEST_CASE(HoughLinesP, int, double, double)
124124
maxGap = GET_PARAM(2);
125125
}
126126

127-
virtual void readRealTestData()
127+
void readRealTestData()
128128
{
129129
Mat img = readImage("shared/pic5.png", IMREAD_GRAYSCALE);
130130
Canny(img, src, 50, 200, 3);
131131

132132
src.copyTo(usrc);
133133
}
134134

135-
virtual void Near(double eps = 0.)
135+
void Near(double eps = 0.)
136136
{
137137
Mat lines_gpu = udst.getMat(ACCESS_READ);
138138

modules/imgproc/test/ocl/test_imgproc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType,
8181
useRoi = GET_PARAM(3);
8282
}
8383

84-
virtual void random_roi()
84+
void random_roi()
8585
{
8686
Size roiSize = randomSize(1, MAX_VALUE);
8787
Border srcBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
@@ -193,7 +193,7 @@ OCL_TEST_P(EqualizeHist, Mat)
193193
struct CornerTestBase :
194194
public ImgprocTestBase
195195
{
196-
virtual void random_roi()
196+
void random_roi()
197197
{
198198
Mat image = readImageType("../gpu/stereobm/aloe-L.png", type);
199199
ASSERT_FALSE(image.empty());
@@ -296,7 +296,7 @@ struct Integral :
296296
useRoi = GET_PARAM(3);
297297
}
298298

299-
virtual void random_roi()
299+
void random_roi()
300300
{
301301
ASSERT_EQ(CV_MAT_CN(type), 1);
302302

modules/imgproc/test/ocl/test_match_template.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, MatchTemplType, bool)
7474
use_roi = GET_PARAM(3);
7575
}
7676

77-
virtual void generateTestData()
77+
void generateTestData()
7878
{
7979
Size image_roiSize = randomSize(2, 100);
8080
Size templ_roiSize = Size(randomInt(1, image_roiSize.width), randomInt(1, image_roiSize.height));

modules/imgproc/test/ocl/test_medianfilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ PARAM_TEST_CASE(MedianFilter, MatDepth, Channels, int, bool)
6767
use_roi = GET_PARAM(3);
6868
}
6969

70-
virtual void generateTestData()
70+
void generateTestData()
7171
{
7272
Size roiSize = randomSize(1, MAX_VALUE);
7373
Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);

0 commit comments

Comments
 (0)