Override system include directories on MacOS

I’m trying to create imported targets to consume OpenCL components. Previously the project relied on include_directories() to specify non-system include directories. However, once I moved to installing components as proper imported targets, when I consume OpenCL::Headers via target_link_libraries(example1 PRIVATE OpenCL::Headers) it picks up the system headers from


How can I tell either when creating the imported target (which I install) or when I consume it, that it should take precendence over the system include?

I suspect that something is not quite correct in the logic of FindOpenCL and it is finding cl.h from the SDK rather than your version. You might try to influence OpenCL_INCLUDE_DIR through the cache or environment.

1 Like