From 1cdedf70fe4685549727bb9ba5e89da85b05370f Mon Sep 17 00:00:00 2001
From: Florent Pruvost <florent.pruvost@inria.fr>
Date: Fri, 13 Apr 2018 13:04:18 +0200
Subject: [PATCH] replace libs in CUDA_LIBRARIES with absolute paths

---
 CMakeLists.txt | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cc4519935..d2bea275f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -408,7 +408,24 @@ if(NOT CHAMELEON_SIMULATION)
     if (CHAMELEON_USE_CUDA)
 
         find_package(CUDA REQUIRED)
-
+        if( CUDA_FOUND )
+          if(WIN32)
+            string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
+          elseif(APPLE)
+            string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
+          else()
+            string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
+          endif()
+          string(REGEX REPLACE "-l" "" CUDA_LIBS "${CUDA_LIBRARIES}")
+          set(CUDA_LIBRARIES)
+          foreach(_lib ${CUDA_LIBS})
+            find_library(CUDA_${_lib}_LIBRARY NAMES ${_lib}
+              HINTS $ENV{CUDA_ROOT}/lib64 ${_lib_env} ${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES} ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})
+            if (CUDA_${_lib}_LIBRARY)
+              list(APPEND CUDA_LIBRARIES ${CUDA_${_lib}_LIBRARY})
+            endif()
+          endforeach()
+        endif ()
         if (CUDA_FOUND)
             message("-- ${Blue}Add definition CHAMELEON_USE_CUDA"
             " - Activate CUDA in Chameleon${ColourReset}")
-- 
GitLab