How to add header file path in CMake file

限于喜欢 提交于 2019-12-06 11:28:36

You will need to put these lines into CMakeLists.txt:

include_directories(/opt/NVIDIA_GPU_Computing_SDK/OpenCL/common/inc)
link_directories(/opt/NVIDIA_GPU_Computing_SDK/OpenCL/common/<lib or something similar>)

add_executable(yourexe src1.c ...)
target_link_libraries(yourexe OpenCL)

But beware that it's not portable, because OpenCL SDK can be somewhere else on another machine. The proper way to do this is to use FindOpenCL.cmake module.

I was looking for FindOpenCL.cmake macro which would work well on Windows, OSX and Linux... I couldn't find any which did work well on every platform, so I wrote new one which I use in couple of projects (webcl-validator and opencl-testsuite).

https://github.com/elhigu/cmake-findopencl

Especially Windows support is improved in this one.

In Windows it checks if 64bit or 32bit lib should be used and it also tries to find libraries from according to environment variables set by Nvidia, Intel and AMD OpenCL SDKs.

It also tries to find .lib in Cygwin, which didn't work with other scripts I tried.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!