livoxGen1: find OpenCL using both CMake & pkgConfig

This commit is contained in:
2025-11-06 09:02:05 -04:00
parent 21bbaf846e
commit f7aba4af4e
+22 -2
View File
@@ -9,8 +9,28 @@ if(ENABLE_STIMBUFFAPI_livoxGen1)
# Find liburing using pkg-config # Find liburing using pkg-config
pkg_check_modules(URING REQUIRED liburing) pkg_check_modules(URING REQUIRED liburing)
# Find OpenCL using pkg-config # Find OpenCL: try find_package first, fall back to pkg-config
pkg_check_modules(OPENCL REQUIRED OpenCL) find_package(OpenCL QUIET)
if(OpenCL_FOUND)
# Normalize find_package variables to match pkg_check_modules naming
set(OPENCL_FOUND TRUE)
set(OPENCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIRS})
# Handle both OpenCL_LIBRARY (singular) and OpenCL_LIBRARIES (plural)
if(OpenCL_LIBRARIES)
set(OPENCL_LIBRARIES ${OpenCL_LIBRARIES})
else()
set(OPENCL_LIBRARIES ${OpenCL_LIBRARY})
endif()
set(OPENCL_LIBRARY_DIRS "")
message(STATUS "Found OpenCL using find_package")
else()
# Fall back to pkg-config
pkg_check_modules(OPENCL OpenCL)
if(NOT OPENCL_FOUND)
message(FATAL_ERROR "Failed to find OpenCL: both find_package and pkg_check_modules failed")
endif()
message(STATUS "Found OpenCL using pkg-config")
endif()
add_library(livoxGen1 SHARED add_library(livoxGen1 SHARED
livoxGen1.cpp livoxGen1.cpp