llvm
5c7bdc81 - [UR][CMake] Fix detection of preinstalled OpenCL (#21531)

Commit
10 days ago
[UR][CMake] Fix detection of preinstalled OpenCL (#21531) There were a couple problems with the OpenCL detection. 1) System install detection didn't work because I had to add the `NO_CMAKE_PACKAGE_REGISTRY` argument to `find_package` to prevent it finding the `FetchContent` checkout on subsequent calls. This CMake module is called at least twice, one for `opencl-aot` and once for the UR OpenCL adapter. 2) If we remove `NO_CMAKE_PACKAGE_REGISTRY` to fix system install detection, then we hit a problem where if there is a system install, but it fails the `check_cxx_source_compiles` check because it doesn't support `cl_khr_spirv_queries`, we had no way to not use the system install it found, so we can't use `find_package` at all. Use `find_path` and `find_library`, whcih is what `find_package(OpenCL)` does internally anyway. Those two functions have nice validator functions we can use that do exactly what we need, to determine if the found OpenCL install is suitable, and if not, don't use it. However, this function is only available with CMake 3.25 (released in 2022) or later, and we currently require `3.20`, but I think saying we don't support system installs with older CMake is reasonable, it still fetches and builds OpenCL from upstream fine. Also do some minor cleanup like making sure there is always a target named `OpenCL` that callers can rely on. Tested the following 3 cases manually: a) No system OpenCL install b) System OpenCL install that's too old c) Working system OpenCL install and all work as expected. Closes: https://github.com/intel/llvm/issues/21513 --------- Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
Author
Parents
Loading