Skip to content

Commit

Permalink
Merge pull request #374 from mmuetzel/cmake
Browse files Browse the repository at this point in the history
CHOLMOD: Don't build libcholmod_cuda when building without CUDA.
  • Loading branch information
DrTimothyAldenDavis authored Sep 1, 2023
2 parents 9a52b72 + 01da186 commit 0cf7fcd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 32 deletions.
17 changes: 13 additions & 4 deletions CHOLMOD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ endif ( )
# find CUDA
#-------------------------------------------------------------------------------

add_subdirectory ( GPU )
if ( SUITESPARSE_CUDA )
# with CUDA
add_subdirectory ( GPU )
message ( STATUS "CUDA libraries: " ${CUDA_LIBRARIES} )
include_directories ( GPU ${CUDAToolkit_INCLUDE_DIRS} )
link_directories ( "GPU" "${CUDA_LIBRARIES}" "/usr/local/cuda/lib64/stubs" "/usr/local/cuda/lib64" )
Expand Down Expand Up @@ -626,9 +626,18 @@ if ( DEMO )
endif ( )

# Libraries required for Demo programs
target_link_libraries ( cholmod_demo PUBLIC CHOLMOD CHOLMOD_CUDA SuiteSparse::SuiteSparseConfig )
target_link_libraries ( cholmod_l_demo PUBLIC CHOLMOD CHOLMOD_CUDA SuiteSparse::SuiteSparseConfig )
target_link_libraries ( cholmod_simple PUBLIC CHOLMOD CHOLMOD_CUDA )
target_link_libraries ( cholmod_demo PUBLIC CHOLMOD SuiteSparse::SuiteSparseConfig )
if ( SUITESPARSE_CUDA )
target_link_libraries ( cholmod_demo PUBLIC CHOLMOD_CUDA )
endif ( )
target_link_libraries ( cholmod_l_demo PUBLIC CHOLMOD SuiteSparse::SuiteSparseConfig )
if ( SUITESPARSE_CUDA )
target_link_libraries ( cholmod_l_demo PUBLIC CHOLMOD_CUDA )
endif ( )
target_link_libraries ( cholmod_simple PUBLIC CHOLMOD )
if ( SUITESPARSE_CUDA )
target_link_libraries ( cholmod_simple PUBLIC CHOLMOD_CUDA )
endif ( )

else ( )

Expand Down
7 changes: 2 additions & 5 deletions CHOLMOD/Config/CHOLMOD_CUDAConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ set ( CHOLMOD_CUDA_VERSION_MINOR @CHOLMOD_VERSION_MINOR@ )
set ( CHOLMOD_CUDA_VERSION_PATCH @CHOLMOD_VERSION_SUB@ )
set ( CHOLMOD_CUDA_VERSION "@CHOLMOD_VERSION_MAJOR@.@CHOLMOD_VERSION_MINOR@.@CHOLMOD_VERSION_SUB@" )

if ( @SUITESPARSE_CUDA@ )
# Look for NVIDIA CUDA toolkit if CHOLMOD_CUDA was built as a non-empty library.
# FindCUDAToolkit ( @CUDAToolkit_VERSION_MAJOR@ REQUIRED )
find_package ( CUDAToolkit @CUDAToolkit_VERSION_MAJOR@ REQUIRED )
endif ( )
# Look for NVIDIA CUDA toolkit
find_package ( CUDAToolkit @CUDAToolkit_VERSION_MAJOR@ REQUIRED )

include ( ${CMAKE_CURRENT_LIST_DIR}/CHOLMOD_CUDATargets.cmake )

Expand Down
37 changes: 14 additions & 23 deletions CHOLMOD/GPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#-------------------------------------------------------------------------------

# cmake 3.22 is required to find the BLAS/LAPACK
cmake_minimum_required ( VERSION 3.19 )
cmake_minimum_required ( VERSION 3.20 )

message ( STATUS "Building CHOLMOD_CUDA version: v"
${CHOLMOD_VERSION_MAJOR}.
Expand All @@ -20,22 +20,15 @@ message ( STATUS "Building CHOLMOD_CUDA version: v"

include ( SuiteSparsePolicy )

if ( SUITESPARSE_CUDA )
project ( cholmod_cuda
VERSION "${CHOLMOD_VERSION_MAJOR}.${CHOLMOD_VERSION_MINOR}.${CHOLMOD_VERSION_SUB}"
LANGUAGES C CXX CUDA )
set ( CMAKE_CUDA_FLAGS "-cudart=static -lineinfo -DSUITESPARSE_CUDA" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSUITESPARSE_CUDA" )
message ( STATUS "C++ flags for CUDA: ${CMAKE_CXX_FLAGS}" )
message ( STATUS "nvcc flags for CUDA: ${CMAKE_CUDA_FLAGS}" )
file ( GLOB CHOLMOD_CUDA_SOURCES "cholmod_gpu.c" "cholmod_l_gpu.c"
"cholmod_gpu_kernels.cu" )
else ( )
project ( cholmod_cuda
VERSION "${CHOLMOD_VERSION_MAJOR}.${CHOLMOD_VERSION_MINOR}.${CHOLMOD_VERSION_SUB}"
LANGUAGES C CXX )
file ( GLOB CHOLMOD_CUDA_SOURCES "cholmod_gpu.c" "cholmod_l_gpu.c" )
endif ( )
project ( cholmod_cuda
VERSION "${CHOLMOD_VERSION_MAJOR}.${CHOLMOD_VERSION_MINOR}.${CHOLMOD_VERSION_SUB}"
LANGUAGES C CXX CUDA )
set ( CMAKE_CUDA_FLAGS "-cudart=static -lineinfo -DSUITESPARSE_CUDA" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSUITESPARSE_CUDA" )
message ( STATUS "C++ flags for CUDA: ${CMAKE_CXX_FLAGS}" )
message ( STATUS "nvcc flags for CUDA: ${CMAKE_CUDA_FLAGS}" )
file ( GLOB CHOLMOD_CUDA_SOURCES "cholmod_gpu.c" "cholmod_l_gpu.c"
"cholmod_gpu_kernels.cu" )

add_library ( CHOLMOD_CUDA SHARED ${CHOLMOD_CUDA_SOURCES} )

Expand Down Expand Up @@ -91,13 +84,11 @@ set_target_properties ( CHOLMOD_CUDA_static PROPERTIES CUDA_SEPARABLE_COMPILATIO
set_target_properties ( CHOLMOD_CUDA_static PROPERTIES POSITION_INDEPENDENT_CODE on )
endif ( )

if ( SUITESPARSE_CUDA )
target_link_libraries ( CHOLMOD_CUDA PRIVATE CUDA::nvrtc CUDA::cudart_static
target_link_libraries ( CHOLMOD_CUDA PRIVATE CUDA::nvrtc CUDA::cudart_static
CUDA::nvToolsExt CUDA::cublas )
if ( NOT NSTATIC )
target_link_libraries ( CHOLMOD_CUDA_static PUBLIC CUDA::nvrtc CUDA::cudart_static
CUDA::nvToolsExt CUDA::cublas )
if ( NOT NSTATIC )
target_link_libraries ( CHOLMOD_CUDA_static PUBLIC CUDA::nvrtc CUDA::cudart_static
CUDA::nvToolsExt CUDA::cublas )
endif ( )
endif ( )

#-------------------------------------------------------------------------------
Expand Down

0 comments on commit 0cf7fcd

Please sign in to comment.