问题描述
在执行find_path时,如何使cmake忽略目录?我正在尝试找到系统的freetype2库,但实际上是在我的项目中找到了该库。
How do I make cmake ignore a directory when doing find_path? I'm trying to find the system's freetype2 library, but instead it is finding the one that inside my project. How do I get it to ignore that?
这是我的FindFreeTypeTwo.cmake的样子
Here's what my FindFreeTypeTwo.cmake looks like
FIND_PATH(_FREETYPE2_INCLUDE_DIR ft2build.h PATH_SUFFIXES freetype2)
FIND_LIBRARY(_FREETYPE2_LIBRARIES NAMES freetype)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype2 DEFAULT_MSG _FREETYPE2_LIBRARIES _FREETYPE2_INCLUDE_DIR)
if (FREETYPE2_FOUND)
set (FREETYPE2_INCLUDE_DIR ${_FREETYPE2_INCLUDE_DIR})
set (FREETYPE2_LIBRARIES ${_FREETYPE2_LIBRARIES})
endif (FREETYPE2_FOUND)
这就是我的文件结构。
\
\ src
| CMakeLists.tst
\ build
\ cmake_config
\ find_packages
| FindFreeTypeTwo.cmake
\ (folder to exclude)
\ (other folders)
推荐答案
您可以在 FIND_PATH()
中更改参数。代替使用 PATH_SUFFIXES
,您可以使用类似
FIND_PATH(_FREETYPE2_INCLUDE_DIR ft2build.h提示ENV FREETYPE2_INCLUDE_DIR PATHS / usr / local /包括)
这是我编写cmake文件时通常使用的东西。
You could change the parameters in the FIND_PATH()
. Instead of using the PATH_SUFFIXES
, you could use something like thisFIND_PATH(_FREETYPE2_INCLUDE_DIR ft2build.h HINTS ENV FREETYPE2_INCLUDE_DIR PATHS /usr/local/include)
This is something I usually use when I write cmake file.
这篇关于cmake-查找忽略目录的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!