问题描述
我的项目布局如下:
- 工作区
- project_a
- project_a-> .h文件在这里
- 根-> .cxx文件在
- project_b-> .h文件在这里
- 根-> .cxx文件在此处
由于我们使用的构建系统,我无法更改目录布局。
标头包含为I cannot change the directory layout due to the build system that we're using.Headers are included as
#include project_a / some_header.h
也来自相应的.cxx文件。
我在根目录中创建了一个CMakeLists.txt文件,该文件通过include_directories(project_a project_b)
,它应该是#include
中给定的路径之前的路径。CLion无法找到并索引我的任何文件also from the corresponding .cxx file.I've created a CMakeLists.txt file in the root directory, that adds all my projects via
include_directories(project_a project_b)
, which should be the path prefixed before the one given in the#include
. CLion does not manage to find and index any of my files.此外,我还有一个自动生成的结构头目录
Additionally, I have an automatically generated directory of headers of structure
- 包括
- lib_a-> .h文件
- lib_b-> .h文件
,我已经对其进行了相应设置,但这也不起作用。
and I've set them up accordingly, but it also does not work.
CLion是否无法解析
#include
中的前缀路径,或者为什么这不起作用?Does CLion not manage to resolve the prefixed path in the
#include
or why is this not working?推荐答案
在CMakeList.txt中,该文件应位于父文件夹 wo中rkspace在这种情况下,请添加文件夹
In CMakeList.txt, which should be located in parent folder, "workspace" folder in that situation, add
set(INCLUDE_DIRECTORIES ./)
例如,如果存在一个父文件夹,其中包含包含文件:
If, for example, there is a parent folder, that holds include files:
- 工作区
- includes_folder
- project_a
- ah
然后CMakeList.txt应包含
Then CMakeList.txt should contain
set(INCLUDE_DIRECTORIES ./) include_directories(includes_folder)
这篇关于告诉CLion使用标头包含路径和前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
- project_a
- includes_folder
- project_a