Should better detect CUDA-vs-GCC version incompatibility
When you try to compile a .cu
file with NVCC, when the host compiler is too new for its tastes (e.g. g++-9 for CUDA 10.2's NVCC) - NVCC complains:
In file included from /usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:83,
from <command-line>:
/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
| ^~~~~
Now, if you try to run CMake on such a system, what you get is this:
CMake Error in /home/eyalroz/src/mine/cuda-api-wrappers/build/CMakeFiles/CMakeTmp/CMakeLists.txt:
CUDA_ARCHITECTURES is empty for target "cmTC_368e9".
CMake Error in /home/eyalroz/src/mine/cuda-api-wrappers/build/CMakeFiles/CMakeTmp/CMakeLists.txt:
CUDA_ARCHITECTURES is empty for target "cmTC_368e9".
CMake Error at /opt/versions/cmake/3.22.0-rc2/share/cmake-3.22/Modules/CMakeDetermineCompilerABI.cmake:49 (try_compile):
Failed to generate test project build system.
Call Stack (most recent call first):
/opt/versions/cmake/3.22.0-rc2/share/cmake-3.22/Modules/CMakeTestCUDACompiler.cmake:19 (CMAKE_DETERMINE_COMPILER_ABI)
CMakeLists.txt:19 (PROJECT)
This really does not help us figure out what's wrong. I don't see why CMake should not detect the "unsupported GCC version" error, or even check the version numbers apriori.
PS - using CMake 3.22.0-rc2 .