removed /EHa flag for cuda compilation
authorAnatoly Baksheev <no@email>
Thu, 23 Aug 2012 11:46:19 +0000 (15:46 +0400)
committerAnatoly Baksheev <no@email>
Thu, 23 Aug 2012 12:53:53 +0000 (16:53 +0400)
cmake/OpenCVDetectCUDA.cmake
modules/gpu/CMakeLists.txt
modules/gpu/test/test_labeling.cpp
modules/imgproc/perf/perf_remap.cpp

index 43e9c81..aa33fe1 100644 (file)
@@ -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)
index 5d2c440..9963ea7 100644 (file)
@@ -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})
index d32dbc1..4eccbf9 100644 (file)
@@ -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;
index 4429e5e..62e02e9 100644 (file)
@@ -52,8 +52,8 @@ PERF_TEST_P( TestRemap, Remap,
                     map1.at<Vec2f>(j, i)[1] = (float)j;
                     break;
                 case CV_16SC2:
-                    map1.at<Vec2s>(j, i)[0] = (float)(src.cols - i);
-                    map1.at<Vec2s>(j, i)[1] = (float)j;
+                    map1.at<Vec2s>(j, i)[0] = (short)(src.cols - i);
+                    map1.at<Vec2s>(j, i)[1] = (short)j;
                     break;
                 default:
                     CV_Assert(0);