From 5827578c63e65f20bbf8efcc059ec5c6b1854c4e Mon Sep 17 00:00:00 2001
From: thorstenhater <24411438+thorstenhater@users.noreply.github.com>
Date: Wed, 3 Mar 2021 19:02:54 +0100
Subject: [PATCH] Fix linking issues caused by nvcc host compiler. (#1412)

Force nvcc to use the c++ compiler used to compile the c++ code.
---
 CMakeLists.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 65c3fe93..a71711d9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -108,6 +108,11 @@ if(ARB_GPU STREQUAL "cuda")
         set(CMAKE_CUDA_ARCHITECTURES 60 70 80)
     endif()
 
+    # This fixes nvcc picking up a wrong host compiler for linking, causing issues
+    # with outdated libraries, eg libstdc++ and std::filesystem. Must happend before
+    # all calls to enable_language(CUDA)
+    set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
+
     enable_language(CUDA)
 
     # Despite native CUDA support, the CUDA package is still required to export
-- 
GitLab