diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake index 43e9c819af..aa33fe18ab 100644 --- a/cmake/OpenCVDetectCUDA.cmake +++ b/cmake/OpenCVDetectCUDA.cmake @@ -77,7 +77,17 @@ if(CUDA_FOUND) unset(CUDA_npp_LIBRARY CACHE) find_cuda_helper_libs(npp) - macro(OCV_CUDA_COMPILE VAR) + macro(ocv_cuda_compile VAR) + foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG) + set(${var}_backup_in_cuda_compile_ "${${var}}") + + # we reomove /EHa as it leasd warnings under windows + string(REPLACE "/EHa" "" ${var} "${${var}}") + + # we remove -ggdb3 flag as it leads to preprocessor errors when compiling CUDA files (CUDA 4.1) + string(REPLACE "-ggdb3" "" ${var} "${${var}}") + endforeach() + if (BUILD_SHARED_LIBS) set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -DCVAPI_EXPORTS) endif() @@ -94,11 +104,12 @@ if(CUDA_FOUND) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-but-set-variable) endif() - # we remove -ggdb3 flag as it leads to preprocessor errors when compiling CUDA files (CUDA 4.1) - set(CMAKE_CXX_FLAGS_DEBUG_ ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "-ggdb3" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - CUDA_COMPILE(${VAR} ${ARGN}) - set(CMAKE_CXX_DEBUG_FLAGS ${CMAKE_CXX_FLAGS_DEBUG_}) + CUDA_COMPILE(${VAR} ${ARGN}) + + foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG) + set(${var} "${${var}_backup_in_cuda_compile_}") + unset(${var}_backup_in_cuda_compile_) + endforeach() endmacro() else() unset(CUDA_ARCH_BIN CACHE) diff --git a/modules/gpu/CMakeLists.txt b/modules/gpu/CMakeLists.txt index 5d2c440fe5..9963ea754a 100644 --- a/modules/gpu/CMakeLists.txt +++ b/modules/gpu/CMakeLists.txt @@ -44,8 +44,9 @@ if (HAVE_CUDA) set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler /wd4251) endif() endif() - + ocv_cuda_compile(cuda_objs ${lib_cuda} ${ncv_cuda}) + #CUDA_BUILD_CLEAN_TARGET() set(cuda_link_libs ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY}) diff --git a/modules/gpu/test/test_labeling.cpp b/modules/gpu/test/test_labeling.cpp index d32dbc1a2f..4eccbf93d6 100644 --- a/modules/gpu/test/test_labeling.cpp +++ b/modules/gpu/test/test_labeling.cpp @@ -87,6 +87,7 @@ namespace { unsigned char* source = (unsigned char*)image.data; int width = image.cols; int height = image.rows; + int step1 = (int)image.step1(); for (int j = 0; j < image.rows; ++j) for (int i = 0; i < image.cols; ++i) @@ -102,7 +103,7 @@ namespace { while (top >= stack) { int* dl = &dist_labels[p.y * pitch + p.x]; - unsigned char* sp = &source[p.y * image.step1() + p.x]; + unsigned char* sp = &source[p.y * step1 + p.x]; dl[0] = cc; @@ -115,11 +116,11 @@ namespace { *top++ = dot::make(p.x - 1, p.y); //bottom - if( p.y < (height - 1) && dl[+pitch] == -1 && inInt(sp[0], sp[+image.step1()])) + if( p.y < (height - 1) && dl[+pitch] == -1 && inInt(sp[0], sp[+step1])) *top++ = dot::make(p.x, p.y + 1); //top - if( p.y > 0 && dl[-pitch] == -1 && inInt(sp[0], sp[-image.step1()])) + if( p.y > 0 && dl[-pitch] == -1 && inInt(sp[0], sp[-step1])) *top++ = dot::make(p.x, p.y - 1); p = *--top; diff --git a/modules/imgproc/perf/perf_remap.cpp b/modules/imgproc/perf/perf_remap.cpp index 4429e5e4e2..62e02e9285 100644 --- a/modules/imgproc/perf/perf_remap.cpp +++ b/modules/imgproc/perf/perf_remap.cpp @@ -52,8 +52,8 @@ PERF_TEST_P( TestRemap, Remap, map1.at(j, i)[1] = (float)j; break; case CV_16SC2: - map1.at(j, i)[0] = (float)(src.cols - i); - map1.at(j, i)[1] = (float)j; + map1.at(j, i)[0] = (short)(src.cols - i); + map1.at(j, i)[1] = (short)j; break; default: CV_Assert(0);