Skip to content

Commit

Permalink
windows-cmake: optional cuda enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Hirsch <michael@scivision.dev>
  • Loading branch information
scivision committed Nov 15, 2021
1 parent d067485 commit 3ed5667
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
16 changes: 16 additions & 0 deletions contrib/windows-cmake/CMakeLists.txt
Expand Up @@ -79,6 +79,20 @@ if(OpenCL_FOUND)
set(HWLOC_HAVE_OPENCL 1)
endif()

set(HAVE_CUDA)
set(HAVE_CUDA_H)
set(HAVE_CUDA_RUNTIME_API_H)
set(HWLOC_HAVE_CUDART)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17)
find_package(CUDAToolkit)
if(CUDAToolkit_FOUND)
set(HAVE_CUDA 1)
set(HAVE_CUDA_H 1)
set(HAVE_CUDA_RUNTIME_API_H 1)
set(HWLOC_HAVE_CUDART 1)
endif()
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/private_config.h.in include/private/autogen/config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/static-components.h.in include/static-components.h)

Expand Down Expand Up @@ -109,11 +123,13 @@ add_library(hwloc
${TOPDIR}/hwloc/topology-x86.c
$<$<BOOL:${HWLOC_HAVE_LIBXML2}>:${TOPDIR}/hwloc/topology-xml-libxml.c>
$<$<BOOL:${HWLOC_HAVE_OPENCL}>:${TOPDIR}/hwloc/topology-opencl.c>
$<$<BOOL:${HAVE_CUDA}>:${TOPDIR}/hwloc/topology-cuda.c>
)

target_link_libraries(hwloc PRIVATE
$<$<BOOL:${HWLOC_HAVE_LIBXML2}>:LibXml2::LibXml2>
$<$<BOOL:${HWLOC_HAVE_OPENCL}>:OpenCL::OpenCL>
"$<$<BOOL:${HAVE_CUDA}>:CUDA::cudart;CUDA::cuda_driver>"
)

if(BUILD_SHARED_LIBS)
Expand Down
8 changes: 4 additions & 4 deletions contrib/windows-cmake/private_config.h.in
Expand Up @@ -43,13 +43,13 @@
/* #undef HAVE_CPUSET_SETID */

/* Define to 1 if we have -lcuda */
/* #undef HAVE_CUDA */
#cmakedefine HAVE_CUDA @HAVE_CUDA@

/* Define to 1 if you have the <cuda.h> header file. */
/* #undef HAVE_CUDA_H */
#cmakedefine HAVE_CUDA_H @HAVE_CUDA_H@

/* Define to 1 if you have the <cuda_runtime_api.h> header file. */
/* #undef HAVE_CUDA_RUNTIME_API_H */
#cmakedefine HAVE_CUDA_RUNTIME_API_H @HAVE_CUDA_RUNTIME_API_H@

/* Define to 1 if you have the declaration of `CL_DEVICE_TOPOLOGY_AMD', and to
0 if you don't. */
Expand Down Expand Up @@ -448,7 +448,7 @@
/* #undef HWLOC_HAVE_CPU_SET_S */

/* Define to 1 if you have the `cudart' SDK. */
/* #undef HWLOC_HAVE_CUDART */
#cmakedefine HWLOC_HAVE_CUDART @HWLOC_HAVE_CUDART@

/* Define to 1 if function `clz' is declared by system headers */
/* #undef HWLOC_HAVE_DECL_CLZ */
Expand Down

0 comments on commit 3ed5667

Please sign in to comment.