MarkSchofield / WindowsToolchain

A repository containing a CMake toolchain for using MSVC
MIT License
106 stars 19 forks source link

Add 'CUDA' awareness #106

Closed MarkSchofield closed 4 months ago

MarkSchofield commented 4 months ago

This PR adds awareness of CUDA, based on the work of @bowie7070, in #104.

In #104, @bowie7070 was setting the CMAKE_CUDA_HOST_COMPILER to the resolved path of the MSVC compiler. Based on the discussion there, it makes sense to set CMAKE_CUDA_HOST_COMPILER, but I'd like to be a little more defensive. With this change, if the CMAKE_CUDA_COMPILER value is set - so demonstrating that the caller wants Cuda support - and the CMAKE_CUDA_HOST_COMPILER isn't set, and the CUDAHOSTCXX environment variable isn't set (both ways that a caller could specify the compiler), then the toolchain will set CMAKE_CUDA_HOST_COMPILER to the value of CMAKE_CXX_COMPILER.

Since Cuda only supports MSVC on Windows - as per the documentation here - this PR only adds support to the Windows.MSVC.toolchain.cmake toolchain.

The PR also adds a Cuda example, that simply calls into the Cuda runtime, and builds it in the CI build, when the CMake preset is windows-msvc-x64.