<div dir="ltr"><span style="color:rgb(0,0,0);font-size:13px">Hello,</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">I'm trying to port an existing project from premake to cmake.</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">I'm trying to avoid modifying the source files while doing so.</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">Right now, we have several libraries (read in different directories) using proto files with imports between them.</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">All imports are made relative to the root of the project.</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">e.g :</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">work/lib1/sublib1/a.proto</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">work/lib1/sublib1/b.proto</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">with a.proto having a link to b.proto like this "import lib1/sublib1/b.proto"</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">If I compile this with an unchanged FindProtobuf.cmake, I do this :</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">protobuf_generate_cpp(PROTO_SRCS PROTO_HRDS a.proto b.proto)</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">add_library(...)</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">the problem being that it looks like the "namespaces" generated by protoc in b.proto do not match the one used in a.proto : it does not compile.</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">Is there a way to make this work ?</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">Otherwise, I made the patch below which solves my problem. Do you think it could be included in cmake ?</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">it defines a new option PROTO_PATH, so the decl above becomes</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">protobuf_generate_cpp(PROTO_SRCS PROTO_HRDS PROTO_PATH ${CMAKE_SOURCE_DIR} a.proto b.proto)</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">With regards</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">David</span><br style="color:rgb(0,0,0);font-size:13px"><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">$ diff share/cmake-3.10/Modules/FindProtobuf.cmake.orig share/cmake-3.10/Modules/FindProtobuf.cmake</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">123c123</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px"><   cmake_parse_arguments(protobuf "" "EXPORT_MACRO;DESCRIPTORS" "" ${ARGN})</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">---</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">>   cmake_parse_arguments(protobuf "" "PROTO_PATH;EXPORT_MACRO;DESCRIPTORS" "" ${ARGN})</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">130a131,139</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">>   set(EXTRA_ARGS "")</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">>   set(OUT_PATH ${CMAKE_CURRENT_BINARY_DIR})</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">>   if(protobuf_PROTO_PATH)</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">>     get_filename_component(ABS_PROTO_PATH ${protobuf_PROTO_PATH} ABSOLUTE)</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">>     set(EXTRA_ARGS "--proto_path=${ABS_PROTO_PATH}")</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">>     file(RELATIVE_PATH PROTO_REL_PATH ${CMAKE_SOURCE_DIR} ${ABS_PROTO_PATH})</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">>     set(OUT_PATH ${CMAKE_BINARY_DIR}/${PROTO_REL_PATH})</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">>   endif()</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">> </span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">198c207,208</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px"><                "--cpp_out=${DLL_EXPORT_DECL}${CMAKE_CURRENT_BINARY_DIR}"</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">---</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">>                ${EXTRA_ARGS}</span><br style="color:rgb(0,0,0);font-size:13px"><span style="color:rgb(0,0,0);font-size:13px">>                "--cpp_out=${DLL_EXPORT_DECL}${OUT_PATH}"</span><br></div>