Link error when building Gromacs on windows with CUDA

I had exactly same problem when it was not possible to link gmx with CUDA files due to LNK2038 error. It is due to CMake uses MultiThreadedDLL as RuntimeLibrary value by default and this behaviour do not depend on shared/static options provided by Gromacs setup.

It is possible to change this behaviour using CMAKE_MSVC_RUNTIME_LIBRARY property introduced in CMake 3.15 (CMAKE_MSVC_RUNTIME_LIBRARY — CMake 3.26.0-rc6 Documentation). I have used “MultiThreaded$<$CONFIG:Debug:Debug>” value and build was successful. Also, I switch off build of shared libraries and gmx and swith on using of static libraries where possible.