- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我了解 target_include_directories()
可以与 PUBLIC
、INTERFACE
或 PRIVATE
结合使用以指定目录的范围或隐私。但是很多过时的代码仍然使用 include_directories()
,而且我不确定使用它们的目标如何处理这些目录。
使用 include_directories()
与使用 target_include_directories(MyTarget PRIVATE ...)
本质上是一样的吗?我看过this类似的问题,但是 include_directories()
是否也没有默认范围行为?
最佳答案
Is using
include_directories()
essentially the same as usingtarget_include_directories(MyTarget PRIVATE ...)
?
是的,对于受 include_directories
影响的每个目标(即在当前CMakeLists.txt
及以下),与PRIVATE
具有相同的效果命令的目标特定版本中的关键字。
Documentation对于 include_directories
说,该命令分配 INCLUDE_DIRECTORIES
目标和目录的属性:
The include directories are added to the
INCLUDE_DIRECTORIES
directory property for the currentCMakeLists
file. They are also added to theINCLUDE_DIRECTORIES
target property for each target in the currentCMakeLists
file.
和目录属性affects在进一步的目标上:
This property is used to populate the
INCLUDE_DIRECTORIES
target property.
正是INCLUDE_DIRECTORIES
目标属性(property) is affected通过 PRIVATE
target_include_directories
的关键词命令:
PRIVATE
andPUBLIC
items will populate theINCLUDE_DIRECTORIES
property of<target>
.PUBLIC
andINTERFACE
items will populate theINTERFACE_INCLUDE_DIRECTORIES
property of<target>
.
关于cmake - include_directories 的默认隐私/范围设置是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57500745/
我有一个带有 .cpp 和 .h 源文件的自定义目标。通常,这些文件包含其他头文件。我想为要查看的头文件添加一个目录。 到目前为止,这听起来很容易,但这里有一个转折点。我正在使用自定义目标和自定义命令
我正在尝试将我的图书馆与其他图书馆链接起来 lib1使用 CMAKE 2.8 .应该说是在Windows上。 在CMakeLists.txt我有: add_library(mylib ${source
我正在用 C++ 编写项目,但在 cmake 中导入库时遇到问题。正在导入的第三方库不会传播包含目录。 根目录/CMakeLists.txt # Top level CMakeLists.txt cm
我正在尝试像 this example 中那样设置我的库和项目使用 ExternalProject_Add。 我有一个这样的图书馆: lib |-include | |-a.hpp |-src | |
这是我的项目树: project | + src | + external | | + foo | | | + include | | | | - foo.hpp | | | + src | | |
我了解 target_include_directories() 可以与 PUBLIC、INTERFACE 或 PRIVATE 结合使用以指定目录的范围或隐私。但是很多过时的代码仍然使用 includ
这个问题在这里已经有了答案: What is the difference between include_directories and target_include_directories in
我正在构建两个 C++ 库(2 个 CMake 项目)。 library2取决于 library1 .我正在 ${CMAKE_INSTALL_INCLUDEDIR}/mylibraries 安装我的第
我决定在我的项目中包含一个库(更具体地说是 yaml-cpp )。由于这两个项目(yaml-cpp 和我的)都使用 CMAKE 进行构建,我决定尝试将 yaml-cpp 目录放在我的根目录中,只使用
在 Meson 中,是否可以从调用 include_directories 创建的对象中获取字符串绝对路径? 我的用例: include_dirs = include_directories(
我有一个 cmake 构建,其中我正在搜索一堆依赖项,即我有很多实例: FIND_PACKAGE(SomePackage) if(SOMEPACKAGE_FOUND) include_direct
我正在尝试使用 cmake,但我是 cmake 和 c++ 的新手。我想要一段代码用于不同的其他程序。文件夹结构是这样的: /modules/foo /modules/foo/src /modules
我需要使用 mangrove(基于 mongo-c-driver 和 mongo-cxx-driver 的 mongo ODM 库)并将其作为 CMake ExternalProject_Add 命令
我在 CMake 中有 2 个项目 L 和 A,假设 L 是一个库,A 是一个依赖于 L 的应用程序。 文件夹层次结构如下: 一个 CMakeLists.txt + headers + src 大号
我的问题主要与 this (unanswered) question 有关在 CMake 邮件列表上。 本质上,我想了解 Visual Studio 2010 生成器幕后 include_direct
我在源代码树中有一个名为“time.h”的文件,与系统“time.h”完全一样。这是无法更改的。我遇到了 cmake 的问题,当我使用 include_library 选项时,它被转换为 -I 标志,
我试图了解可以在 target_include_directories 中指定的范围之间的区别,特别是 PRIVATE和 INTERFACE .文档说(特定上下文是仅 header 库): The I
我似乎在使用 -I 设置包含路径( include_directories() )时遇到问题CMake 中的命令。我的项目目录如下: Root | - CMakeLists.txt | - libs
我正在使用 CMake 来构建我的项目,我有以下几行: include_directories(${LLVM_INCLUDE_DIRS}) 其中,经过评估 LLVM_INCLUDE_DIRS , 评估
我们正在尝试交叉编译某个软件,并且在大多数情况下它一直有效。但是,包含文件分为多个目录,如果目录位于 sysroot 树之外,有时 CMake 决定不将其添加到 Makefile 上的包含列表中。 工
我是一名优秀的程序员,十分优秀!