[CMake] Enable NCCL only when enabling CUDA or ROCm support (#5516)
Conditionally enable NCCL depending on CUDA and ROCM
Before this change NCCL support was enabled unconditionally, even
when building without CUDA or ROCM support.
This caused the command:
$ ./build.sh --enable_training
To trigger the following cmake warning
-- Could NOT find NCCL (missing: NCCL_INCLUDE_DIR NCCL_LIBRARY)
CMake Warning at CMakeLists.txt:1282 (message):
NCCL is not found. Please use --nccl_home to specify the path of NCCL.
Otherwise, NCCL is disabled.
This is a spurious warning because the user did not ask to search for NCCL.