From 31c639407cd5efad3a5f736cec19329751f3d896 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Wed, 18 Oct 2023 17:47:07 -0400 Subject: [PATCH] COMP: Revisit initialization of Autoscoper_RENDERING_BACKEND 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. --- SuperBuild/External_Autoscoper.cmake | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/SuperBuild/External_Autoscoper.cmake b/SuperBuild/External_Autoscoper.cmake index a151cec..3083ee2 100644 --- a/SuperBuild/External_Autoscoper.cmake +++ b/SuperBuild/External_Autoscoper.cmake @@ -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)