Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" fails with misleading error message
Hello,
We have a usecase where we split our cuda compiler into 2 conan packages. For simplicity lets say
- compiler binaries like
nvcc
in one conan package - Header includes and Libraries in another conan package
Problem :
-
nvcc
compiler always looks for headers relative tobin
directory, since we have header files in another package, we provide the include header paths viaCMAKE_CUDA_FLAGS
. - Now it should ideally find the header files in
include
paths (which it does) and crash during linking because it cannot find libraries to link, since we dont specify the library include paths. - But since
set(__compiler_id_require_success TRUE)
is set only after calling__determine_compiler_id_test(testflags userflags)
function atleast once in/CMakeDetermineCompilerId.cmake
file, cmake fails to capture this error and then calls the compiler again with only test flags and to crash again with same errorcc1plus: fatal error: cuda_runtime.h: No such file or directory
, this I think is misleading
Solution :
- cmake should capture error during the first compiler call with
userflags
andtestflags
. settingset(__compiler_id_require_success TRUE)
before the call to__determine_compiler_id_test(testflags userflags)
could also be a solution.