CMake find_path包括目录前缀 [英] CMake find_path include directory prefix
问题描述
我为OpenNI写了一个最小的Find * .cmake。找到头文件
I am writing a minimal Find*.cmake for OpenNI. To find the header files I wrote
find_path(OPENNI_INCLUDE_PATH XnOS.h)
这是正常工作的(OPENNI_INCLUDE_PATH的值为/ usr / include / ni)。
然而,在我的文件中,我必须包含
which is working as expected (OPENNI_INCLUDE_PATH has the value /usr/include/ni). However, in my files I have to include the headers with
#include <ni/XnOS.h>
如何摆脱ni前缀,所以我可以写
How can I get rid of the ni prefix, so I can write
#include <XnOS.h>
第一个include的问题是包含了一个XnCppWrapper.h,这个文件又包含了一些Xn * .h头,但没有ni前缀。
The problem with the first include is that a XnCppWrapper.h gets included and this file includes again some Xn*.h headers, but without the ni prefix. This results in a compiler error.
推荐答案
始终使用 find_path $ c> $ c>匹配
#include
语句中的一个。
Always have the path you use for find_path
match the one in your #include
statements.
如果您要 #include< ni / XnOS.h>
您应该写入
find_path(OPENNI_INCLUDE_PATH ni/XnOS.h)
如果您想要 #include< XnOS.h> ;
,使用
find_path(OPENNI_INCLUDE_PATH XnOS.h)
请务必事先确定要使用哪一个,然后粘贴。混合同一个库的多个包含路径是确保不必要地使构建环境过于复杂的方法。
Just be sure to make up your mind beforehand which one you want to use and stick to it. Mixing several include paths for the same library is a sure way to unnecessarily overcomplicate the build environment.
这篇关于CMake find_path包括目录前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!