KhronosGroup/OpenCL-SDK

OpenCL_INCLUDE_DIRS and OpenCL_LIBRARIES are not set.

pjueon opened this issue · 1 comments

pjueon commented

Hello, I'm currently building and testing the OpenCL-SDK, and I have a question.

First, I built and installed the OpenCL-SDK using CMake. Then, in another CMake project, I called find_package(OpenCL REQUIRED) to use OpenCL.

The OpenCL_FOUND variable is set to 1, and I can successfully build it by calling target_link_libraries(MyProject OpenCL::OpenCL). However, the OpenCL_INCLUDE_DIRS and OpenCL_LIBRARIES variables are not being set and are empty.

As far as I know, when find_package succeeds, it's a standard CMake practice for <PackageName>_INCLUDE_DIRS and <PackageName>_LIBRARIES variables to be set. I might be wrong since I'm not very familiar with CMake, but I believe this is the typical behavior in CMake.

I'm building other projects that use OpenCL, such as clFFT. In these projects, they directly reference the OpenCL_INCLUDE_DIRS and OpenCL_LIBRARIES variables in their CMakeLists.txt to build. Of course, I could modify the CMakeLists.txt files of these projects to call target_link_libraries(SomeProject OpenCL::OpenCL) directly, but it would be more convenient if <PackageName>_INCLUDE_DIRS and <PackageName>_LIBRARIES variables were automatically set when find_package succeeds. This would make it easier to work with a variety of projects.

If I'm mistaken about something, please let me know. Thanks.

Hi @pjueon, do I understand correctly that you'd like the old-school style variables be set when a user specifically opts in to detecting the OpenCL SDK in Config mode? The Module mode of find_package unfortunately by defaults hides the package config file and only triggers if the scripts opt-in using the CONFIG flag or the user overrides the default via CMAKE_FIND_PACKAGE_PREFER_CONFIG globally.

It has not occured to me someone would want to mix'n'match features this way because Module mode finds this SDK just as well, there are no additional targets or libraries exposed via these variables, IMHO it would be erronous to expect the utility libraries to appear as part of there variables. So long as its installed in a system default location or the user points to it using one of the ways listed in Config Mode Search Procedure, it should work. Let me know if this is what you meant.