protobuf
protobuf copied to clipboard
Rogue semicolon appearing in protobuf_generate_cpp() CMake function when specifying a Protobuf_include_path
What version of protobuf and what language are you using? Version: 3.11.0 Language: C++
What operating system (Linux, Windows, ...) and version? Windows 10 v1909
What runtime / compiler are you using (e.g., python version or gcc version) -- Building for: Visual Studio 16 2019 -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
What did you do? Steps to reproduce the behavior:
- Create CMake project and 2 example proto files
- 1 proto file must import the other
- Specify the include path for protobuf
set(Protobuf_IMPORT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/proto_schemas/}")
- Call protobuf_generate_cpp
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS EXPORT_MACRO DLL_EXPORT proto_schemas/Proto1.proto proto_schemas/Proto2.proto)
The build fails for some unknown reason. After digging into protobuf-config.cmake I found where the custom command for protoc is written. I added a print statement to see what ARGS looks like. Here's what the full protoc command looks like for the first proto file:
protoc --cpp_out dllexport_decl=DLL_EXPORT:C:/users/myuser/project/out_Windows/chimera_exec -I;C:/users/myuser/project/proto_schemas C:/users/myuser/project/proto_schemas/Proto1.proto
If you look closely, you'll notice a semicolon after -I
. I believe this is causing an issue and preventing the files from being generated. Some way that the cmake file is computing that _protobuf_include_path variable in protobuf-config.cmake is adding that semi colon. I read the code and it looks like it should be generating the include path by itself (Though I could be mistaken). But until i called set(Protobuf_IMPORT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/proto_schemas/}")
, the -I
value was always blank.
Hopefully my bug description is clear. Let me know if you need any more information. Thanks for your help!