Build OpenCL block only if enabled with -DENABLE_OPENCL=ON

This commit is contained in:
Carles Fernandez 2019-08-02 14:52:40 +02:00
parent 834ad56ffc
commit c79b8ea4f3
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 6 additions and 4 deletions

View File

@ -2056,13 +2056,15 @@ set_package_properties(OPENCL PROPERTIES
PURPOSE "Used in some processing block implementations."
TYPE OPTIONAL
)
if(NOT OPENCL_FOUND)
set(ENABLE_OPENCL OFF)
endif()
if(ENABLE_OPENCL)
find_package(OPENCL)
if(DEFINED ENV{DISABLE_OPENCL})
set(DISABLE_OPENCL TRUE)
endif()
if(DISABLE_OPENCL)
set(OPENCL_FOUND FALSE)
set(ENABLE_OPENCL OFF)
else()
if(OPENCL_FOUND)
message(STATUS "OpenCL has been found and will be used by some processing blocks")
@ -2070,7 +2072,7 @@ if(ENABLE_OPENCL)
endif()
endif()
if(ENABLE_GENERIC_ARCH)
set(OPENCL_FOUND FALSE)
set(ENABLE_OPENCL OFF)
message(STATUS "ENABLE_GENERIC_ARCH is set to ON so the use of OpenCL has been disabled.")
endif()
if(NOT OPENCL_FOUND)

View File

@ -111,7 +111,7 @@ target_link_libraries(algorithms_libs
Glog::glog
)
if(OPENCL_FOUND)
if(ENABLE_OPENCL)
target_link_libraries(algorithms_libs PUBLIC OpenCL::OpenCL)
target_include_directories(algorithms_libs PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/opencl