nareshmlx/opencv-pr huggingface dataset:
**File:** modules/dnn/test/test_layers.cpp
**Change Type:** modified
**Context:** PR #24977: Primitive 1D Tests
**Review Line:** 782

**Code Changes:**
```diff
+        input_shape.erase(input_shape.begin());
+
+    cv::Mat input1 = cv::Mat(input_shape, CV_32F, 1.0);
+    cv::Mat input2 = cv::Mat(input_shape, CV_32F, 1.0);
+    cv::randu(input1, 0.0, 1.0);
+    cv::randu(input2, 0.0, 1.0);
+
+    // Dynamically select the operation
+    cv::Mat output_ref;
+    if (operation == "sum") {
+        output_ref = input1 + input2;
```

Review comment:
> `0.0` Wrong input for "div" which leads to inaccurate results.
**File:** modules/dnn/test/test_layers.cpp
**Change Type:** modified
**Context:** PR #24977: Primitive 1D Tests
**Review Line:** 775

**Code Changes:**
```diff
+    lp.type = "Eltwise";
+    lp.name = operation + "_Layer";
+    lp.set("operation", operation);
+    Ptr<EltwiseLayer> layer = EltwiseLayer::create(lp);
+
+    std::vector<int> input_shape = {batch_size, 1};
+    if (batch_size == 0)
+        input_shape.erase(input_shape.begin());
+
+    cv::Mat input1 = cv::Mat(input_shape, CV_32F, 1.0);
+    cv::Mat input2 = cv::Mat(input_shape, CV_32F, 1.0);
```

Review comment:
1D of size 1? Where is test about 1D of size `C`?
**File:** modules/stitching/include/opencv2/stitching/detail/warpers.hpp
**Change Type:** modified
**Context:** PR #24989: remove bypass for ABI check in warpPointBackward

**Code Changes:**
```diff
@@ -77,15 +77,7 @@ class CV_EXPORTS RotationWarper
     @param R Camera rotation matrix
     @return Backward-projected point
     */
-#if CV_VERSION_MAJOR == 4
-    virtual Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R)
-    {
-        CV_UNUSED(pt); CV_UNUSED(K); CV_UNUSED(R);
-        CV_Error(Error::StsNotImplemented, "");
-    }
```

Review comment:
Please fix identation.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24980: dnn cleanup: On-fly-quantization removal
**Review Line:** 632

**Code Changes:**
```diff
@@ -259,15 +259,6 @@ CV__DNN_INLINE_NS_BEGIN
          */
         virtual void forward(InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals);
 
-        /** @brief Tries to quantize the given layer and compute the quantization parameters required for fixed point implementation.
-         *  @param[in] scales input and output scales.
-         *  @param[in] zeropoints input and output zeropoints.
-         *  @param[out] params Quantized parameters required for fixed point implementation of that layer.
-         *  @returns True if layer can be quantized.
-         */
-        virtual bool tryQuantize(const std::vector<std::vector<float> > &scales,
-                                 const std::vector<std::vector<int> > &zeropoints, LayerParams& params);
-
         /** @brief Given the @p input blobs, computes the output @p blobs.
          *  @param[in]  inputs  the input blobs.
```

Review comment:
I suppose that `getInputDetails` and `getOutputDetails` should be presumed. We support pre-quantized networks and the mentioned API is not related to on-fly quantization.
**File:** modules/dnn/test/test_int8_layers.cpp
**Change Type:** modified
**Context:** PR #24980: dnn cleanup: On-fly-quantization removal
**Review Line:** 9

**Code Changes:**
```diff
 
+// The tests are disabled, because on-fly quantization was removed in https://github.com/opencv/opencv/pull/24980
+// To be restored, when test models are quantized outsize of OpenCV
+#if 0
+
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
@@ -1389,3 +1393,5 @@ TEST_P(Test_Int8_nets, YOLOv4_tiny)
 INSTANTIATE_TEST_CASE_P(/**/, Test_Int8_nets, dnnBackendsAndTargetsInt8());
 
```

Review comment:
The file contains formatting changes only. Let's revert it to reduce branch conflicts.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24980: dnn cleanup: On-fly-quantization removal
**Review Line:** 632

**Code Changes:**
```diff
@@ -259,15 +259,6 @@ CV__DNN_INLINE_NS_BEGIN
          */
         virtual void forward(InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals);
 
-        /** @brief Tries to quantize the given layer and compute the quantization parameters required for fixed point implementation.
-         *  @param[in] scales input and output scales.
-         *  @param[in] zeropoints input and output zeropoints.
-         *  @param[out] params Quantized parameters required for fixed point implementation of that layer.
-         *  @returns True if layer can be quantized.
-         */
-        virtual bool tryQuantize(const std::vector<std::vector<float> > &scales,
-                                 const std::vector<std::vector<int> > &zeropoints, LayerParams& params);
-
         /** @brief Given the @p input blobs, computes the output @p blobs.
          *  @param[in]  inputs  the input blobs.
```

Review comment:
They are only used in `test_int8_layers.cpp` which quantizes nets on the fly (thus you need to quantize the inputs manually with the `inputDetails`). I don't think they are useful anymore given the fact that we are removing on-fly quantization.
**File:** modules/dnn/test/test_int8_layers.cpp
**Change Type:** modified
**Context:** PR #24980: dnn cleanup: On-fly-quantization removal
**Review Line:** 9

**Code Changes:**
```diff
 
+// The tests are disabled, because on-fly quantization was removed in https://github.com/opencv/opencv/pull/24980
+// To be restored, when test models are quantized outsize of OpenCV
+#if 0
+
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
@@ -1389,3 +1393,5 @@ TEST_P(Test_Int8_nets, YOLOv4_tiny)
 INSTANTIATE_TEST_CASE_P(/**/, Test_Int8_nets, dnnBackendsAndTargetsInt8());
 
```

Review comment:
Tests in this file are **ALL** using on-fly quantization. It is not realistic to convert all test models to quantized ones. I think we will remove these tests eventually and create new ones which test existing int8-quantized layers with handcrafted model and data.
**File:** modules/dnn/test/test_int8_layers.cpp
**Change Type:** modified
**Context:** PR #24980: dnn cleanup: On-fly-quantization removal
**Review Line:** 9

**Code Changes:**
```diff
 
+// The tests are disabled, because on-fly quantization was removed in https://github.com/opencv/opencv/pull/24980
+// To be restored, when test models are quantized outsize of OpenCV
+#if 0
+
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
@@ -1389,3 +1393,5 @@ TEST_P(Test_Int8_nets, YOLOv4_tiny)
 INSTANTIATE_TEST_CASE_P(/**/, Test_Int8_nets, dnnBackendsAndTargetsInt8());
 
```

Review comment:
No, no need to touch this file, just revert changes here.
**File:** modules/dnn/test/test_int8_layers.cpp
**Change Type:** modified
**Context:** PR #24980: dnn cleanup: On-fly-quantization removal
**Review Line:** 9

**Code Changes:**
```diff
 
+// The tests are disabled, because on-fly quantization was removed in https://github.com/opencv/opencv/pull/24980
+// To be restored, when test models are quantized outsize of OpenCV
+#if 0
+
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
@@ -1389,3 +1393,5 @@ TEST_P(Test_Int8_nets, YOLOv4_tiny)
 INSTANTIATE_TEST_CASE_P(/**/, Test_Int8_nets, dnnBackendsAndTargetsInt8());
 
```

Review comment:
Cannot use multi-line comment `/**/` to comment out the whole file if those not formatted to use `//` instead.
**File:** modules/dnn/test/test_int8_layers.cpp
**Change Type:** modified
**Context:** PR #24980: dnn cleanup: On-fly-quantization removal
**Review Line:** 9

**Code Changes:**
```diff
 
+// The tests are disabled, because on-fly quantization was removed in https://github.com/opencv/opencv/pull/24980
+// To be restored, when test models are quantized outsize of OpenCV
+#if 0
+
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
@@ -1389,3 +1393,5 @@ TEST_P(Test_Int8_nets, YOLOv4_tiny)
 INSTANTIATE_TEST_CASE_P(/**/, Test_Int8_nets, dnnBackendsAndTargetsInt8());
 
```

Review comment:
I got your point on comments. The major issue I see is gap in quantized layers testing and technical dept. I propose the following: - Drop large networks tests, e.g. yolo for now. - convert existing test cases with single layer, a.k.a. `testLayer` to quanitzed and push them to extra as separate folder.
**File:** modules/dnn/test/test_int8_layers.cpp
**Change Type:** modified
**Context:** PR #24980: dnn cleanup: On-fly-quantization removal
**Review Line:** 9

**Code Changes:**
```diff
 
+// The tests are disabled, because on-fly quantization was removed in https://github.com/opencv/opencv/pull/24980
+// To be restored, when test models are quantized outsize of OpenCV
+#if 0
+
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
@@ -1389,3 +1393,5 @@ TEST_P(Test_Int8_nets, YOLOv4_tiny)
 INSTANTIATE_TEST_CASE_P(/**/, Test_Int8_nets, dnnBackendsAndTargetsInt8());
 
```

Review comment:
> convert existing test cases with single layer There are still too many test layers. There are 42 `Test_Int8_layers` instances and each can have >10 test cases, resulting in >100 test cases in total (also note they are different formats, CAFFE, TF, ONNX ...). I propose to test existing int8 layers instead, e.g. one, two or more test cases for each int8 layers, depending on parameters.
**File:** modules/dnn/test/test_int8_layers.cpp
**Change Type:** modified
**Context:** PR #24980: dnn cleanup: On-fly-quantization removal
**Review Line:** 9

**Code Changes:**
```diff
 
+// The tests are disabled, because on-fly quantization was removed in https://github.com/opencv/opencv/pull/24980
+// To be restored, when test models are quantized outsize of OpenCV
+#if 0
+
 #include "test_precomp.hpp"
 #include "npy_blob.hpp"
 #include <opencv2/dnn/shape_utils.hpp>
@@ -1389,3 +1393,5 @@ TEST_P(Test_Int8_nets, YOLOv4_tiny)
 INSTANTIATE_TEST_CASE_P(/**/, Test_Int8_nets, dnnBackendsAndTargetsInt8());
 
```

Review comment:
> Cannot use multi-line comment /**/ to comment out the whole file because need to use `#if 0` instead.
**File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -73,6 +73,10 @@ if(POLICY CMP0077)
   cmake_policy(SET CMP0077 NEW)  # CMake 3.13+: option() honors normal variables.
 endif()
 
+if(POLICY CMP0091)
+  cmake_policy(SET CMP0091 NEW) # CMake 3.15+: leave MSVC runtime selection out of default CMAKE_<LANG>_FLAGS_<CONFIG> flags
+endif()
+
 if(POLICY CMP0146)
   cmake_policy(SET CMP0146 OLD)  # CMake 3.27+: use CMake FindCUDA if available.
```

Review comment:
serch => search
**File:** cmake/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -1,10 +1,10 @@
 if((WIN32 AND NOT MSVC) OR OPENCV_CMAKE_FORCE_CUDA)
-  message(STATUS "CUDA compilation is disabled (due to only Visual Studio compiler supported on your platform).")
+  message(STATUS "CUDA: Compilation is disabled (due to only Visual Studio compiler supported on your platform).")
   return()
 endif()
 
 if((NOT UNIX AND CV_CLANG) OR OPENCV_CMAKE_FORCE_CUDA)
-  message(STATUS "CUDA compilation is disabled (due to Clang unsupported on your platform).")
+  message(STATUS "CUDA: Compilation is disabled (due to Clang unsupported on your platform).")
```

Review comment:
There are 375 changes in this file which size is 577 lines on 4.x branch (more that 50%). To avoid mess and/or breaking of existed legacy code my proposal is creating a copy of this file, cleanup dead code, and specify code for the new CUDA support.
**File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support
**Review Line:** 77

**Code Changes:**
```diff
@@ -73,6 +73,10 @@ if(POLICY CMP0077)
   cmake_policy(SET CMP0077 NEW)  # CMake 3.13+: option() honors normal variables.
 endif()
 
+if(POLICY CMP0091)
+  cmake_policy(SET CMP0091 NEW) # CMake 3.15+: leave MSVC runtime selection out of default CMAKE_<LANG>_FLAGS_<CONFIG> flags
+endif()
+
 if(POLICY CMP0146)
   cmake_policy(SET CMP0146 OLD)  # CMake 3.27+: use CMake FindCUDA if available.
 endif()
```

Review comment:
Please follow the existed pattern: `if(POLICY CMP0091)`
**File:** cmake/OpenCVDetectCUDALanguage.cmake
**Change Type:** added
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+#######################
+# Previously in FindCUDA and still required for FindCUDNN
+macro(FIND_CUDA_HELPER_LIBS _name)
+  if(CMAKE_CROSSCOMPILING AND (ARM OR AARCH64))
+    set(_cuda_cross_arm_lib_dir "lib/stubs")
+  endif()
+  find_library(CUDA_${_name}_LIBRARY ${_name}
+    NAMES ${_name}
+    PATHS "${CUDAToolkit_LIBRARY_ROOT}"
```

Review comment:
ccache is a little picky with `-Xcompiler` flag, this form will work with latest ccache We should do the same modification on `cmake/OpenCVDetectCUDA.cmake`. Or should I do a separate PR, once this one is merged ? ```suggestion set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler=-DCVAPI_EXPORTS) ```
**File:** cmake/OpenCVDetectCUDALanguage.cmake
**Change Type:** added
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+#######################
+# Previously in FindCUDA and still required for FindCUDNN
+macro(FIND_CUDA_HELPER_LIBS _name)
+  if(CMAKE_CROSSCOMPILING AND (ARM OR AARCH64))
+    set(_cuda_cross_arm_lib_dir "lib/stubs")
+  endif()
+  find_library(CUDA_${_name}_LIBRARY ${_name}
+    NAMES ${_name}
+    PATHS "${CUDAToolkit_LIBRARY_ROOT}"
```

Review comment:
```suggestion set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler=-fPIC) ```
**File:** cmake/OpenCVDetectCUDALanguage.cmake
**Change Type:** added
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+#######################
+# Previously in FindCUDA and still required for FindCUDNN
+macro(FIND_CUDA_HELPER_LIBS _name)
+  if(CMAKE_CROSSCOMPILING AND (ARM OR AARCH64))
+    set(_cuda_cross_arm_lib_dir "lib/stubs")
+  endif()
+  find_library(CUDA_${_name}_LIBRARY ${_name}
+    NAMES ${_name}
+    PATHS "${CUDAToolkit_LIBRARY_ROOT}"
```

Review comment:
```suggestion set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler=-fno-finite-math-only) ```
**File:** cmake/OpenCVDetectCUDALanguage.cmake
**Change Type:** added
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+#######################
+# Previously in FindCUDA and still required for FindCUDNN
+macro(FIND_CUDA_HELPER_LIBS _name)
+  if(CMAKE_CROSSCOMPILING AND (ARM OR AARCH64))
+    set(_cuda_cross_arm_lib_dir "lib/stubs")
+  endif()
+  find_library(CUDA_${_name}_LIBRARY ${_name}
+    NAMES ${_name}
+    PATHS "${CUDAToolkit_LIBRARY_ROOT}"
```

Review comment:
> ccache is a little picky with -Xcompiler flag, this form will work with latest ccache I don't use ccache (at the moment) how can I tell if these fixes worked as it builds fine either way? > We should do the same modification on cmake/OpenCVDetectCUDA.cmake. I'm not sure if its necessary if ccache doesn't work when CUDA is not a first class language?
**File:** cmake/OpenCVDetectCUDALanguage.cmake
**Change Type:** added
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+#######################
+# Previously in FindCUDA and still required for FindCUDNN
+macro(FIND_CUDA_HELPER_LIBS _name)
+  if(CMAKE_CROSSCOMPILING AND (ARM OR AARCH64))
+    set(_cuda_cross_arm_lib_dir "lib/stubs")
+  endif()
+  find_library(CUDA_${_name}_LIBRARY ${_name}
+    NAMES ${_name}
+    PATHS "${CUDAToolkit_LIBRARY_ROOT}"
```

Review comment:
> > We should do the same modification on cmake/OpenCVDetectCUDA.cmake. > > I'm not sure if its necessary if ccache doesn't work when CUDA is not a first class language? I will submit a PR to CMake so their `run_nvcc.cmake` takes into account ccache. We could postpone this change to later but it could be better to sync the changes as it does not break the current build.
**File:** cmake/OpenCVDetectCUDALanguage.cmake
**Change Type:** added
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+#######################
+# Previously in FindCUDA and still required for FindCUDNN
+macro(FIND_CUDA_HELPER_LIBS _name)
+  if(CMAKE_CROSSCOMPILING AND (ARM OR AARCH64))
+    set(_cuda_cross_arm_lib_dir "lib/stubs")
+  endif()
+  find_library(CUDA_${_name}_LIBRARY ${_name}
+    NAMES ${_name}
+    PATHS "${CUDAToolkit_LIBRARY_ROOT}"
```

Review comment:
> > ccache is a little picky with -Xcompiler flag, this form will work with latest ccache > > I don't use ccache (at the moment) how can I tell if these fixes worked as it builds fine either way? You need to have `ccache` installed and OpenCV should find it when using `-DENABLE_CCACHE=ON`
**File:** cmake/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -1,10 +1,10 @@
 if((WIN32 AND NOT MSVC) OR OPENCV_CMAKE_FORCE_CUDA)
-  message(STATUS "CUDA compilation is disabled (due to only Visual Studio compiler supported on your platform).")
+  message(STATUS "CUDA: Compilation is disabled (due to only Visual Studio compiler supported on your platform).")
   return()
 endif()
 
 if((NOT UNIX AND CV_CLANG) OR OPENCV_CMAKE_FORCE_CUDA)
-  message(STATUS "CUDA compilation is disabled (due to Clang unsupported on your platform).")
+  message(STATUS "CUDA: Compilation is disabled (due to Clang unsupported on your platform).")
```

Review comment:
Sometimes I need to compile OpenCV as static library but still needs it to be compiled with dynamic CRT. I was using `BUILD_WITH_STATIC_CRT`. So it is perhaps better to use this flag than `BUILD_SHARED_LIBS`? So I am not sure how the NEW logic is supposed to handle the 4 cases on Windows - `BUILD_SHARED_LIBS=OFF` `BUILD_WITH_STATIC_CRT=OFF` - `BUILD_SHARED_LIBS=OFF` `BUILD_WITH_STATIC_CRT=ON` - `BUILD_SHARED_LIBS=ON` `BUILD_WITH_STATIC_CRT=OFF` - `BUILD_SHARED_LIBS=ON` `BUILD_WITH_STATIC_CRT=ON` (perhaps this one is not supposed to work)
**File:** cmake/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -1,10 +1,10 @@
 if((WIN32 AND NOT MSVC) OR OPENCV_CMAKE_FORCE_CUDA)
-  message(STATUS "CUDA compilation is disabled (due to only Visual Studio compiler supported on your platform).")
+  message(STATUS "CUDA: Compilation is disabled (due to only Visual Studio compiler supported on your platform).")
   return()
 endif()
 
 if((NOT UNIX AND CV_CLANG) OR OPENCV_CMAKE_FORCE_CUDA)
-  message(STATUS "CUDA compilation is disabled (due to Clang unsupported on your platform).")
+  message(STATUS "CUDA: Compilation is disabled (due to Clang unsupported on your platform).")
```

Review comment:
As you mention I missed that the existing logic ``` if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT) dynamic CRT else static CRT ``` from https://github.com/opencv/opencv/blob/588ddf1b181aa7243144b27d65fc7690fb89e344/cmake/OpenCVCRTLinkage.cmake#L36 allows > BUILD_SHARED_LIBS=OFF BUILD_WITH_STATIC_CRT=OFF and doesn't respect > BUILD_SHARED_LIBS=ON BUILD_WITH_STATIC_CRT=ON To be consistent shouldn't the new logic be the same i.e. ``` if(MSVC_RUNTIME_SET_BY_ABSTRACTION STREQUAL "NEW") if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT) set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} " /MT") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} " /MTd") else() set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} " /MD") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} " /MDd") ```
**File:** cmake/OpenCVDetectCUDALanguage.cmake
**Change Type:** added
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+#######################
+# Previously in FindCUDA and still required for FindCUDNN
+macro(FIND_CUDA_HELPER_LIBS _name)
+  if(CMAKE_CROSSCOMPILING AND (ARM OR AARCH64))
+    set(_cuda_cross_arm_lib_dir "lib/stubs")
+  endif()
+  find_library(CUDA_${_name}_LIBRARY ${_name}
+    NAMES ${_name}
+    PATHS "${CUDAToolkit_LIBRARY_ROOT}"
```

Review comment:
> and calling make after make clean takes a matter of seconds? Yes the compilation should be faster. Linking the libraries still need time.
**File:** cmake/OpenCVDetectCUDALanguage.cmake
**Change Type:** added
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -0,0 +1,154 @@
+#######################
+# Previously in FindCUDA and still required for FindCUDNN
+macro(FIND_CUDA_HELPER_LIBS _name)
+  if(CMAKE_CROSSCOMPILING AND (ARM OR AARCH64))
+    set(_cuda_cross_arm_lib_dir "lib/stubs")
+  endif()
+  find_library(CUDA_${_name}_LIBRARY ${_name}
+    NAMES ${_name}
+    PATHS "${CUDAToolkit_LIBRARY_ROOT}"
```

Review comment:
> That's the output without the changes > > > --generate-code=arch=compute_86,code=[sm_86] -Xcompiler=-fPIC -D_FORCE_INLINES -Xcompiler -DCVAPI_EXPORTS -fPIC "-Xcompiler You are right, this gets : `Result: direct_cache_hit`. Perhaps on 4.x branch (which I am using), the content of the command line is slightly different and it breaks ccache. Or perhaps it depends on the version of the CUDA Toolkit / `nvcc`. I have tested with CUDA 10.1 and 11.4. > with the changes > > > --generate-code=arch=compute_86,code=[sm_86] -Xcompiler=-fPIC -D_FORCE_INLINES -Xcompiler=-DCVAPI_EXPORTS -Xcompiler=-fPIC "-Xcompiler= You also got : `Result: direct_cache_hit` > Can you get ccache to work on windows for nvcc? I don't know. Just using it on Ubuntu for the moment.
**File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -73,6 +73,10 @@ if(POLICY CMP0077)
   cmake_policy(SET CMP0077 NEW)  # CMake 3.13+: option() honors normal variables.
 endif()
 
+if(POLICY CMP0091)
+  cmake_policy(SET CMP0091 NEW) # CMake 3.15+: leave MSVC runtime selection out of default CMAKE_<LANG>_FLAGS_<CONFIG> flags
+endif()
+
 if(POLICY CMP0146)
   cmake_policy(SET CMP0146 OLD)  # CMake 3.27+: use CMake FindCUDA if available.
```

Review comment:
```suggestion if(UNIX AND CUDA_PATH AND NOT ENV{CUDA_PATH}) ``` `if` should use `ENV{CUDA_PATH}` to check variable correctly
**File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -73,6 +73,10 @@ if(POLICY CMP0077)
   cmake_policy(SET CMP0077 NEW)  # CMake 3.13+: option() honors normal variables.
 endif()
 
+if(POLICY CMP0091)
+  cmake_policy(SET CMP0091 NEW) # CMake 3.15+: leave MSVC runtime selection out of default CMAKE_<LANG>_FLAGS_<CONFIG> flags
+endif()
+
 if(POLICY CMP0146)
   cmake_policy(SET CMP0146 OLD)  # CMake 3.27+: use CMake FindCUDA if available.
```

Review comment:
Apparently this branch doesn't work as expected. `check_language(CUDA)` doesn't detect nvcc. I've added more debug prints: ``` -- Checking for CUDA compiler in default location (/usr/local/cuda) CMake Warning at CMakeLists.txt:685 (message): Detecting CUDA language (default)... (CUDA_PATH=/usr/local/cuda / ENV{CUDA_PATH}=/usr/local/cuda) CMake Warning at CMakeLists.txt:687 (message): CMAKE_CUDA_COMPILER=NOTFOUND ``` ~It seems that changing environment variables here do not affect `check_language(CUDA)`, I tried also prepending it's location to `PATH` also without success. While setting `CUDA_PATH` or `PATH` in the shell before running cmake helps with detection.~ I found the issue: setting ENV{CUDA_PATH} __after__ `check_language(CUDA)` does not affect search process and consequent `check_language` will fails. **upd:** unsetting `CMAKE_CUDA_COMPILER` variable in both cache and local scope helps with detection: ```.cmake unset(CMAKE_CUDA_COMPILER CACHE) unset(CMAKE_CUDA_COMPILER) ```