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)