diff --git a/CMakeLists.txt b/CMakeLists.txt index cc45199357af33028360c43b664b47549bf22c2e..d2bea275fbed9a6ffe63058864bcb63b56129bd1 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}")