From f7aba4af4ef47ee45f60782e6764bfa3aef82f2d Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Thu, 6 Nov 2025 09:02:05 -0400 Subject: [PATCH] livoxGen1: find OpenCL using both CMake & pkgConfig --- stimBuffApis/livoxGen1/CMakeLists.txt | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/stimBuffApis/livoxGen1/CMakeLists.txt b/stimBuffApis/livoxGen1/CMakeLists.txt index 63f74ab..bfc777d 100644 --- a/stimBuffApis/livoxGen1/CMakeLists.txt +++ b/stimBuffApis/livoxGen1/CMakeLists.txt @@ -9,8 +9,28 @@ if(ENABLE_STIMBUFFAPI_livoxGen1) # Find liburing using pkg-config pkg_check_modules(URING REQUIRED liburing) - # Find OpenCL using pkg-config - pkg_check_modules(OPENCL REQUIRED OpenCL) + # Find OpenCL: try find_package first, fall back to pkg-config + 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 livoxGen1.cpp