cmake 为什么我不需要在find_package之后“include_directories”?

c8ib6hqw  于 2023-03-12  发布在  其他
关注(0)|答案(1)|浏览(181)

最近,我用openvino完成了我的项目,并编写了CMakeLists.txt用于编译和生成目标,正如我所做的:

find_package(InferenceEngine 2.1 QUIET)

根据InferenceEngineConfig.cmake,我知道将定义以下变量:

# This will define the following variables:
# InferenceEngine_FOUND - True if the system has the 
# Inference Engine library
# InferenceEngine_INCLUDE_DIRS - Inference Engine include 
  directories
# InferenceEngine_LIBRARIES - Inference Engine libraries

在执行find_package()之后,我执行:

include_directories(${OpenCV_INCLUDE_DIRS} ${InferenceEngine_INCLUDE_DIRS} )

并做所有它需要的事情来获取共享库,这正是我所需要的。
然而,当我删除这一行时:
#include_directories(${OpenCV_INCLUDE_DIRS} ${InferenceEngine_INCLUDE_DIRS} )
一切仍然工作正常,这真的让我困惑...谁能告诉我这一切背后的逻辑?提前感谢!

a8jjtwal

a8jjtwal1#

可能与OpenCVConfig.cmakeInferenceEngineConfig.cmake文件的内容有关,我在OpenCVConfig.cmake文件中发现了一个注解:
include_directories(${OpenCV_INCLUDE_DIRS}) # Not needed for CMake >= 2.8.11
因此,我认为include_directories()find_package(OpenCV)完成时已经执行。

相关问题