protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Rogue semicolon appearing in protobuf_generate_cpp() CMake function when specifying a Protobuf_include_path

Open vpaladino778 opened this issue 4 years ago • 0 comments

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:

  1. Create CMake project and 2 example proto files
  2. 1 proto file must import the other
  3. Specify the include path for protobuf
set(Protobuf_IMPORT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/proto_schemas/}")
  1. 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!

vpaladino778 avatar Apr 02 '20 18:04 vpaladino778