@@ -34,25 +34,23 @@ set(CMAKE_CUDA_COMPILER_VERSION ${CMAKE_CUDA_COMPILER_VERSION} PARENT_SCOPE)
34
34
set (CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS} PARENT_SCOPE )
35
35
36
36
37
- # nvcc uses static cudartlibrary by default
37
+ # MSVC nvcc uses static cudartlibrary by default, and other platforms use shared cudartlibrary.
38
38
# add `-cudart shared` or `-cudart=shared` according system into CMAKE_CUDA_FLAGS/GINKGO_CUDA_COMPILER_FLAGS
39
- # to force nvcc to use dynamic cudart library.
39
+ # to force nvcc to use dynamic cudart library in MSVC .
40
40
find_library (CUDA_RUNTIME_LIBS_DYNAMIC cudart
41
41
HINT ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES} )
42
42
find_library (CUDA_RUNTIME_LIBS_STATIC cudart_static
43
43
HINT ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES} )
44
-
45
- if ("${CMAKE_CUDA_FLAGS} " MATCHES "-cudart(=| )shared" OR "${GINKGO_CUDA_COMPILER_FLAGS} " MATCHES "-cudart(=| )shared" )
46
- set (CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_DYNAMIC} " CACHE STRING "Path to a library" FORCE )
47
- else ()
48
- set (CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_STATIC} " CACHE STRING "Path to a library" FORCE )
49
- if (NOT MSVC )
50
- set (THREADS_PREFER_PTHREAD_FLAG ON )
51
- find_package (Threads REQUIRED )
52
- # link cudart_static need rt, pthread, and dl
53
- set (CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_STATIC} ;rt;Threads::Threads;-Wl,--no-as-needed;dl" CACHE STRING "Path to a library" FORCE )
44
+ if (MSVC )
45
+ if ("${CMAKE_CUDA_FLAGS} " MATCHES "-cudart(=| )shared" OR "${GINKGO_CUDA_COMPILER_FLAGS} " MATCHES "-cudart(=| )shared" )
46
+ set (CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_DYNAMIC} " CACHE STRING "Path to a library" FORCE )
47
+ else ()
48
+ set (CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_STATIC} " CACHE STRING "Path to a library" FORCE )
54
49
endif ()
50
+ else ()
51
+ set (CUDA_RUNTIME_LIBS "${CUDA_RUNTIME_LIBS_DYNAMIC} " CACHE STRING "Path to a library" FORCE )
55
52
endif ()
53
+
56
54
find_library (CUBLAS cublas
57
55
HINT ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES} )
58
56
find_library (CUSPARSE cusparse
0 commit comments