Re: [cmake-developers] [PATCH] Fix error in compiling C++ files generating by protobuf compiler when .proto files are organized in a directory hierarchy
I think the user is supposed not to pass full paths to PROTOBUF_GENERATE_CPP. Because if user does so, there is a more severe bug right now in the code: if user provides both /some/path/A.proto and /another/path/A.proto to PROTOBUF_GENERATE_CPP, C++ file of both A.proto files will be generated in ${CMAKE_CURRENT_BINARY_DIR}/A.cpp. In other words C++ file of one A.proto overwrites C++ of the other A.proto file. So I think the original author of FindProtobuf.cmake has intended the user to provide relative paths to .proto files, and he/she has been mostly considering cases where .proto files are placed right in the same directory as CMakeLists.txt, rather than more complex cases like .proto files organized in a directory hierarchy which I'm recently hit a bug about. On the other hand I can't think of a genuine use case where user needs to use PROTOBUF_GENERATE_CPP on absolute paths. Long story short I think it is safe to assume PROTOBUF_GENERATE_CPP is intended to be used on relative paths. But again maybe I'm missing something! So correct me if I'm wrong. :) On Mon, May 26, 2014 at 11:58 PM, David Cole wrote: > Maybe I'm missing something. Is it guaranteed that all callers of > PROTOBUF_GENERATE_CPP will pass non-full-path names for the .proto source > files? > > If so, then I retract my statement. But I don't think you can guarantee > that. > > > David C. > > -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] [PATCH] Fix error in compiling C++ files generating by protobuf compiler when .proto files are organized in a directory hierarchy
${FILE_PATH} is PATH part of ${FIL} and ${FIL} is path of each of .proto files relative to CMakeLists.txt as the user has entered in CMakeLists.txt. So ${FIL} and consequently ${FILE_PATH} cannot contain drive letters in a genuine usage scenario. Or I'm missing something. On Mon, May 26, 2014 at 3:45 PM, David Cole wrote: > > Hi everybody there, > > > > Subject says it all. See the attached patch please. > > > > (Didn't care enough to leave hg for git to generate the patch. Sorry.) > > > FILE_PATH is likely to contain "C:" or some other drive letter on > Windows. It is therefore unsuitable for using to construct a sub-path > underneath CMAKE_CURRENT_BINARY_DIR. > > You don't have to care enough to leave hg, but we do have to care > enough to make sure CMake still works on all the platforms it's > intended to work on. > > This patch may fix your particular use case, but it is not generally > correct, and therefore, unlikely to be adopted into upstream CMake. > There must be a better solution, that will work on all platforms... > > > David C. > > > -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
[cmake-developers] [PATCH] Fix error in compiling C++ files generating by protobuf compiler when .proto files are organized in a directory hierarchy
Hi everybody there, Subject says it all. See the attached patch please. (Didn't care enough to leave hg for git to generate the patch. Sorry.) # HG changeset patch # User Ebrahim Mohammadi # Date 1401098735 -16200 # Mon May 26 14:35:35 2014 +0430 # Node ID 0b2fc1eb05f57c9147b5cfb77b7e1887b443f3b2 # Parent a9bf99d5c158d15d204838ab7dca6fb588ad0018 Fix error in compiling C++ files generating by protobuf compiler when .proto files are organized in a directory hierarchy. diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -173,7 +173,9 @@ set(${HDRS}) foreach(FIL ${ARGN}) get_filename_component(ABS_FIL ${FIL} ABSOLUTE) -get_filename_component(FIL_WE ${FIL} NAME_WE) +get_filename_component(FILE_NAME_WE ${FIL} NAME_WE) +get_filename_component(FILE_PATH ${FIL} PATH) +set(FIL_WE "${FILE_PATH}/${FILE_NAME_WE}") list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h") -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers