[CMake] FindProtobuf error: _protobuf_include_path empty
Antonio Mancina
antomicx at gmail.com
Tue Feb 5 10:32:30 EST 2013
Hi all,
I've been fighting against this error for the last two hours.
When I try to setup a cmake-based project which builds some protobuf
related stuff, something strange happens.
My sample cmake directives follow:
================================
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS
${CMAKE_SRC_DIR}/Libraries/FileA.proto
${CMAKE_SRC_DIR}/Libraries/FileB.proto
)
add_library(MyLibrary SHARED
${PROTO_SRCS}
)
target_link_libraries(MyLibrary
${PROTOBUF_LIBRARIES}
)
================================
When building this code, the build system was silently failing at building
the pb.h and pb.cc files. I followed all the code path within the module
and found that the problem is related to the _protobuf_include_path not
being given any value before the PROBUF_GENERATE_CPP call, so that the row
list(APPEND _protobuf_include_path -I ${ABS_PATH})
translates to
-I ;/the/path/in/abs_path
with the semi-colon between the -I and the path. This gives rise to
problems in protoc invocation.
I solved this by introducing the following if-then-else:
list(LENGTH _protobuf_include_path _list_num)
if(${_list_num} EQUAL 0)
set(_protobuf_include_path -I ${ABS_PATH})
else()
list(APPEND _protobuf_include_path -I ${ABS_PATH})
endif()
but I'd like to understand what I'm doing wrong and why I'm seeing this.
Thanks all!
A.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130205/95455df0/attachment-0001.htm>
More information about the CMake
mailing list