Skip to content

Commit

Permalink
COMP: Revisit initialization of Autoscoper_RENDERING_BACKEND
Browse files Browse the repository at this point in the history
Revisit approach originally introduced in 6912ab0 (ENH: Enable CUDA on
Windows and Linux) to support initializing Autoscoper_RENDERING_BACKEND
based on env. variable of the same name.

This will allow to enable the CUDA rendering backend only in build environment
where CUDA is available.
  • Loading branch information
jcfr committed Oct 18, 2023
1 parent 6912ab0 commit 31c6394
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions SuperBuild/External_Autoscoper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,28 @@ if(NOT DEFINED ${proj}_DIR AND NOT ${SUPERBUILD_TOPLEVEL_PROJECT}_USE_SYSTEM_${p
)
endif()

# set(Autoscoper_OPENCL_USE_ICD_LOADER TRUE)
# if(APPLE)
# set(Autoscoper_OPENCL_USE_ICD_LOADER FALSE)
# endif()

set(Autoscoper_OPENCL_USE_ICD_LOADER FALSE)
if(APPLE)
set(_msg "")
if(DEFINED ENV{Autoscoper_RENDERING_BACKEND})
set(_msg " (initialized from env. variable)")
set(Autoscoper_RENDERING_BACKEND $ENV{Autoscoper_RENDERING_BACKEND})
elseif(NOT DEFINED Autoscoper_RENDERING_BACKEND)
set(_msg " (default value)")
set(Autoscoper_RENDERING_BACKEND "OpenCL")
endif()

ExternalProject_Message(${proj} "Setting Autoscoper_RENDERING_BACKEND to ${Autoscoper_RENDERING_BACKEND}${_msg}")

if(NOT "${Autoscoper_RENDERING_BACKEND}" MATCHES "^(CUDA|OpenCL)$")
message(FATAL_ERROR "Autoscoper_RENDERING_BACKEND variable is expected to be set to CUDA or OpenCL")
endif()

if(Autoscoper_RENDERING_BACKEND STREQUAL "OpenCL")
set(Autoscoper_OPENCL_USE_ICD_LOADER TRUE)
if(APPLE)
set(Autoscoper_OPENCL_USE_ICD_LOADER FALSE)
endif()
else()
set(Autoscoper_RENDERING_BACKEND "CUDA")
set(Autoscoper_OPENCL_USE_ICD_LOADER FALSE)
endif()

if(UNIX AND NOT APPLE)
Expand Down

0 comments on commit 31c6394

Please sign in to comment.