**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:
You could subjectively tell by the speed of recompile: ```` make make clean make ```` Second make should be faster for ALL files (not only CXX/C) For a more objective/quantitative way, you need to see if compiling CUDA is cached and/or if is cached on first compile. You will need to add log to ccache in `$HOME/.ccache/ccache.conf` a line ``` log_file = /home/dgeld/.ccache/log.txt ``` In the log, you will see that the caching is failing : `Failed; falling back to running the real compiler` ``` [2023-08-26T08:38:00.211404 10953] Hostname: dgeld-VirtualBox [2023-08-26T08:38:00.211407 10953] Working directory: /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda [2023-08-26T08:38:00.211414 10953] Compiler: /usr/local/cuda-11.4/bin/nvcc [2023-08-26T08:38:00.211417 10953] Compiler type: nvcc [2023-08-26T08:38:00.211460 10953] ,"-fdata-sections","-Wa,--noexecstack","-fsigned-char","-Wno-psabi","-fsigned-char","-W","-Wall","-Wreturn-type","-Wnon-virtual-dtor","-Waddress","-Wsequence-point","-Wformat","-Wformat-security","-Wmissing-declarations","-Winit-self","-Wpointer-arith","-Wuninitialized","-Wno-comment","-Wno-strict-overflow","-fdiagnostics-show-option","-pthread","-fomit-frame-pointer","-ffunction-sections","-fdata-sections","-fvisibility=hidden","-Wno-undef","-Wno-enum-compare","-Wno-unused-function","-Wno-shadow","-Wno-unused-but-set-variable","-O3","-DNDEBUG","-DNDEBUG" is not a regular file, not considering as input file [2023-08-26T08:38:00.211468 10953] arch=compute_72,code=sm_72 is not a regular file, not considering as input file [2023-08-26T08:38:00.211474 10953] arch=compute_87,code=sm_87 is not a regular file, not considering as input file [2023-08-26T08:38:00.211523 10953] Source file: /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/modules/core/src/cuda/gpu_mat_nd.cu [2023-08-26T08:38:00.211527 10953] Object file: /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat_nd.cu.o [2023-08-26T08:38:00.211588 10953] Hashing CWD /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda [2023-08-26T08:38:00.211597 10953] Trying direct lookup [2023-08-26T08:38:00.211660 10953] Filesystem has less than 100 MiB free space, not using inode cache [2023-08-26T08:38:00.211668 10953] Manifest key: ef40rbo157eoo2lm5l0alo1p57ehhujkk [2023-08-26T08:38:00.211676 10953] No ef40rbo157eoo2lm5l0alo1p57ehhujkk in local storage [2023-08-26T08:38:00.211775 10953] Running preprocessor [2023-08-26T08:38:00.211797 10953] Executing /usr/local/cuda-11.4/bin/nvcc -m64 -Xcompiler ,"-fdata-sections","-Wa,--noexecstack","-fsigned-char","-Wno-psabi","-fsigned-char","-W","-Wall","-Wreturn-type","-Wnon-virtual-dtor","-Waddress","-Wsequence-point","-Wformat","-Wformat-security","-Wmissing-declarations","-Winit-self","-Wpointer-arith","-Wuninitialized","-Wno-comment","-Wno-strict-overflow","-fdiagnostics-show-option","-pthread","-fomit-frame-pointer","-ffunction-sections","-fdata-sections","-fvisibility=hidden","-Wno-undef","-Wno-enum-compare","-Wno-unused-function","-Wno-shadow","-Wno-unused-but-set-variable","-O3","-DNDEBUG","-DNDEBUG" -gencode arch=compute_72,code=sm_72 -gencode arch=compute_87,code=sm_87 -Xcompiler -Xcompiler -fPIC --std=c++14 -ccbin /usr/bin/aarch64-linux-gnu-gcc -D_USE_MATH_DEFINES -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int -D__OPENCV_BUILD=1 -D_FORCE_INLINES -DCVAPI_EXPORTS -DNVCC -I/usr/local/cuda-11.4/targets/aarch64-linux/include -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/modules/core/include -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/modules/core -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv_contrib/modules/cudev/include -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/3rdparty/zlib -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/3rdparty/zlib -E -o /run/user/1000/ccache-tmp/cpp_stdout.tmp.80bAgr.i /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/modules/core/src/cuda/gpu_mat_nd.cu [2023-08-26T08:38:00.213663 10953] Preprocessor gave exit status 1 [2023-08-26T08:38:00.213684 10953] Failed; falling back to running the real compiler [2023-08-26T08:38:00.213696 10953] Executing /usr/local/cuda-11.4/bin/nvcc /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/modules/core/src/cuda/gpu_mat_nd.cu -c -o /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat_nd.cu.o -ccbin /usr/bin/aarch64-linux-gnu-gcc -m64 -D_USE_MATH_DEFINES -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int -D__OPENCV_BUILD=1 -Xcompiler ,"-fdata-sections","-Wa,--noexecstack","-fsigned-char","-Wno-psabi","-fsigned-char","-W","-Wall","-Wreturn-type","-Wnon-virtual-dtor","-Waddress","-Wsequence-point","-Wformat","-Wformat-security","-Wmissing-declarations","-Winit-self","-Wpointer-arith","-Wuninitialized","-Wno-comment","-Wno-strict-overflow","-fdiagnostics-show-option","-pthread","-fomit-frame-pointer","-ffunction-sections","-fdata-sections","-fvisibility=hidden","-Wno-undef","-Wno-enum-compare","-Wno-unused-function","-Wno-shadow","-Wno-unused-but-set-variable","-O3","-DNDEBUG","-DNDEBUG" -gencode arch=compute_72,code=sm_72 -gencode arch=compute_87,code=sm_87 -D_FORCE_INLINES -Xcompiler -DCVAPI_EXPORTS -Xcompiler -fPIC --std=c++14 -Xlinker --unresolved-symbols=ignore-in-shared-libs -DNVCC -I/usr/local/cuda-11.4/targets/aarch64-linux/include -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/modules/core/include -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/modules/core -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv_contrib/modules/cudev/include -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/3rdparty/zlib -I/home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/3rdparty/zlib [2023-08-26T08:38:00.213700 10953] Result: direct_cache_miss [2023-08-26T08:38:00.213703 10953] Result: local_storage_read_miss [2023-08-26T08:38:00.213705 10953] Result: preprocessor_error ``` when it works, you will see, ccache storing: ``` [2023-08-26T08:49:41.990771 5558 ] Storing embedded entry #1 .o (3344152 bytes) from /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o ``` or a cache hit ``` [2023-08-26T08:52:36.495780 8494 ] Compiler: /usr/local/cuda-11.4/bin/nvcc [2023-08-26T08:52:36.495782 8494 ] Compiler type: nvcc [2023-08-26T08:52:36.495827 8494 ] ,"-fdata-sections","-Wa,--noexecstack","-fsigned-char","-Wno-psabi","-fsigned-char","-W","-Wall","-Wreturn-type","-Wnon-virtual-dtor","-Waddress","-Wsequence-point","-Wformat","-Wformat-security","-Wmissing-declarations","-Winit-self","-Wpointer-arith","-Wuninitialized","-Wno-comment","-Wno-strict-overflow","-fdiagnostics-show-option","-pthread","-fomit-frame-pointer","-ffunction-sections","-fdata-sections","-fvisibility=hidden","-Wno-undef","-Wno-enum-compare","-Wno-unused-function","-Wno-shadow","-Wno-unused-but-set-variable","-O3","-DNDEBUG","-DNDEBUG" is not a regular file, not considering as input file [2023-08-26T08:52:36.495833 8494 ] arch=compute_72,code=sm_72 is not a regular file, not considering as input file [2023-08-26T08:52:36.495841 8494 ] arch=compute_87,code=sm_87 is not a regular file, not considering as input file [2023-08-26T08:52:36.495886 8494 ] Source file: /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/modules/core/src/cuda/gpu_mat.cu [2023-08-26T08:52:36.495890 8494 ] Object file: /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o [2023-08-26T08:52:36.495951 8494 ] Hashing CWD /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda [2023-08-26T08:52:36.495960 8494 ] Trying direct lookup [2023-08-26T08:52:36.496036 8494 ] Filesystem has less than 100 MiB free space, not using inode cache [2023-08-26T08:52:36.496048 8494 ] Manifest key: 02cer5pejds1qpa3bqlfbgj8f8s31ktbk [2023-08-26T08:52:36.496065 8494 ] Retrieved 02cer5pejds1qpa3bqlfbgj8f8s31ktbk from local storage (/home/dgeld/.ccache/0/2/cer5pejds1qpa3bqlfbgj8f8s31ktbkM) [2023-08-26T08:52:36.498064 8494 ] Got result key from manifest [2023-08-26T08:52:36.498073 8494 ] Result key: 00a48hbqsck6d582k5lv8svag1vj5t9q6 [2023-08-26T08:52:36.498327 8494 ] Retrieved 00a48hbqsck6d582k5lv8svag1vj5t9q6 from local storage (/home/dgeld/.ccache/0/0/a48hbqsck6d582k5lv8svag1vj5t9q6R) [2023-08-26T08:52:36.500838 8494 ] Reading embedded entry #0 <stderr> (614 bytes) [2023-08-26T08:52:36.500877 8494 ] Reading embedded entry #1 .o (3344152 bytes) [2023-08-26T08:52:36.500891 8494 ] Writing to /home/dgeld/src/david/opencv/opencv_cuda/tmp2/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o [2023-08-26T08:52:36.502660 8494 ] Succeeded getting cached result [2023-08-26T08:52:36.502688 8494 ] Result: direct_cache_hit [2023-08-26T08:52:36.502693 8494 ] Result: local_storage_hit [2023-08-26T08:52:36.502696 8494 ] Result: local_storage_read_hit [2023-08-26T08:52:36.502698 8494 ] Result: local_storage_read_hit ```