I wish to use proto and managed by cmake.
Suppose the files are as follow
.
├── app1
│ ├── app1.cpp
│ └── app1.proto
├── CMakeLists.txt
├── common
│ ├── bar
│ │ ├── bar.proto
│ │ └── CMakeLists.txt
│ └── foo
│ ├── CMakeLists.txt
│ └── foo.proto
└── README.md
If I wanna just generate some cpp files, I can just use command
$ protoc --cpp_out=build common/bar/bar.proto
$ protoc --cpp_out=build common/foo/foo.proto
and the desired files can be generated.
However, if I use CMake, it will report an error as follow :
[ 14%] Running C++ protocol buffer compiler on foo.proto
Scanning dependencies of target FooLib
[ 28%] Building CXX object common/foo/CMakeFiles/FooLib.dir/foo.pb.cc.o
Linking CXX static library libFooLib.a
[ 28%] Built target FooLib
[ 42%] Running C++ protocol buffer compiler on bar.proto
Scanning dependencies of target BarLib
[ 57%] Building CXX object common/bar/CMakeFiles/BarLib.dir/bar.pb.cc.o
/Users/yu/Workspace/res/proto/project/build/common/bar/bar.pb.cc:79:5: error: no member named 'protobuf_AddDesc_common_2ffoo_2ffoo_2eproto' in the global namespace
::protobuf_AddDesc_common_2ffoo_2ffoo_2eproto();
~~^
1 error generated.
make[2]: *** [common/bar/CMakeFiles/BarLib.dir/bar.pb.cc.o] Error 1
make[1]: *** [common/bar/CMakeFiles/BarLib.dir/all] Error 2
make: *** [all] Error 2
Any help are appreciated.