Skip to content

Commit

Permalink
ENH: Update Autoscoper modernizing CUDA integration
Browse files Browse the repository at this point in the history
This commit updates the Autoscoper project by replacing the deprecated
FindCUDA CMake module with the more robust and first-class support for
CUDA language. The changes leverage the following key features introduced
in various CMake versions:

- CMake 3.8: Support by the Makefile Generators and the Ninja generator
  on Linux, macOS, and Windows
  See https://cmake.org/cmake/help/latest/release/3.8.html#cuda\

- CMake 3.9: Support by the Visual Studio Generators for VS 2010 and above.
  See https://cmake.org/cmake/help/latest/release/3.9.html#languages

- CMake 3.17: Introduction of FindCUDAToolkit
  See https://cmake.org/cmake/help/latest/release/3.17.html#modules
  and https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html#module:FindCUDAToolkit

List of Autoscoper changes:

```
$ git shortlog 7df4365ec..da782db91 --no-merges
Jean-Christophe Fillion-Robin (2):
      COMP: Update minimum CMake version from 3.8 to 3.17.5
      COMP: Modernize CUDA integration using FindCUDAToolkit CMake module
```
  • Loading branch information
jcfr committed Feb 13, 2024
1 parent 1b3eaa4 commit 6f7acb2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
29 changes: 24 additions & 5 deletions SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,32 @@ set(${proj}_DEPENDS
)

if(DEFINED ENV{SlicerAutoscoperM_CUDA_PATH})
set(ENV{CUDA_PATH} $ENV{SlicerAutoscoperM_CUDA_PATH})
file(TO_CMAKE_PATH "$ENV{SlicerAutoscoperM_CUDA_PATH}" _cuda_path)
if(CMAKE_GENERATOR MATCHES "Visual Studio")
# https://cmake.org/cmake/help/latest/variable/CMAKE_GENERATOR_TOOLSET.html#visual-studio-toolset-selection
if(NOT "${CMAKE_GENERATOR_TOOLSET}" MATCHES "cuda=")
set(_generator_toolset_key_value "cuda=${_cuda_path}")
if(NOT "${CMAKE_GENERATOR_TOOLSET}" STREQUAL "")
set(CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET},${_generator_toolset_key_value}")
else()
set(CMAKE_GENERATOR_TOOLSET "${_generator_toolset_key_value}")
endif()
endif()
else()
# See https://cmake.org/cmake/help/latest/envvar/CUDACXX.html#cudacxx
set(ENV{CUDACXX} $ENV{_cuda_path}/bin/nvcc)
endif()
endif()

find_package(CUDA)
if(CUDA_FOUND)
# Variable expected by find_package(CUDA) also used in Autoscoper
mark_as_superbuild(VARS CUDA_TOOLKIT_ROOT_DIR PROJECTS Autoscoper-CUDA)
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
# Variable expected by CUDA language also used in Autoscoper
if(CMAKE_GENERATOR MATCHES "Visual Studio")
mark_as_superbuild(VARS CMAKE_GENERATOR_TOOLSET PROJECTS Autoscoper-CUDA)
else()
mark_as_superbuild(VARS CMAKE_CUDA_COMPILER PROJECTS Autoscoper-CUDA)
endif()
list(APPEND ${proj}_DEPENDS
Autoscoper-CUDA
)
Expand Down
4 changes: 2 additions & 2 deletions SuperBuild/External_Autoscoper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ if(NOT DEFINED ${proj}_DIR AND NOT ${SUPERBUILD_TOPLEVEL_PROJECT}_USE_SYSTEM_${p

ExternalProject_SetIfNotDefined(
Slicer_${proj}_GIT_REPOSITORY
"https://github.com/BrownBiomechanics/Autoscoper.git"
"https://github.com/jcfr/Autoscoper.git"
QUIET
)

ExternalProject_SetIfNotDefined(
Slicer_${proj}_GIT_TAG
"7df4365ecb1919fa10cb3e67a836467db0686f2e"
"da782db91bfe8eb9eda0bc28ceb49eae52432c02"
QUIET
)

Expand Down

0 comments on commit 6f7acb2

Please sign in to comment.