Compiling a third party project on macOS, I stumbled upon the following compilation error after running make
:
Scanning dependencies of target[...]
[ 33%] Building CXX object CMakeFiles/[...].dir/main.cpp.o
In file included from /Users/[...]/main.cpp:11:
/Users/[...]/CLCalculator.h:14:10: fatal error: 'CL/cl.h' file not found
#include <CL/cl.h>
^
1 error generated.
make[2]: *** [CMakeFiles/[...].dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/[...].dir/all] Error 2
make: *** [all] Error 2
Unfortunately the application was originally not intended for macOS / OS X platforms. There are quite some examples of similar encounters in the vastness of the internet. But… there is a simple way to make your the respective code cross-plattform and compatible with macOS / OS X:
#if defined(__APPLE__) || defined(__MACOSX)
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif
Just replace the #include <CL/cl.h>
statement with the snippet above and run make
again – great…