Include path has been specified but still failed to include the header in the path in a Bazel C++ project

Viewed 18

I have projects with a directory structure like that

---root
|  |--src
|    |--project1
|      |--model
|      |  |--incude
|      |  |  |--model
|      |  |    |--modelA.hpp
|      |  |    |--modelB.hpp
|      |  |--modelA.cpp
|      |  |--modelB.cpp
|      |  |--BUILD #1
|      |...
|      |--view
|      |...
|      |--common
|      |  |--include
|      |    |--common
|      |      |--data_type.hpp 
|      |--BUILD #2
|--WORKSPACE

As I have other package in this project and some of them use the same self-defined data type, I defined them in a package named common.

Now I include the data_type.hpp in file modelA.hpp

...
#include "common/data_type.hpp
...

Refering to the stage3 example in the tutorial, the BUID(#1) is like that

cc_library(
  name = "modelA",
  hdrs = "include/model/modelA.hpp",
  deps = ["//src/project/common:data_type"],
  copts = ["-Isrc/project/common/include"],
)

and the BUILD(#2) which defines the depedency module data_typeis like that

cc_library(
  name = "data_type",
  hdrs = ["include/common/data_type.hpp"],
  visibility = ["//visibility:public"],
)

However, when I built the code, I got

src/project/model/include/model/modelA.hpp: fatal error: common/data_type.hpp: No such file or directory

Why I have defined copts = ["-Isrc/heimdallr/common/include"] but still got this error?

0 Answers
Related