If protobuf-c is already installed on the system, the cmake build can
generate an error like the following when using the ninja backend:
edmonds@chase{0}:/tmp/protobuf-c$ cmake -S build-cmake -B build -G Ninja
[...]
edmonds@chase{0}:/tmp/protobuf-c$ ninja -v -C build
ninja: Entering directory `build'
[1/19] cd /tmp/protobuf-c/build && /usr/bin/cmake -E env PATH="/tmp/protobuf-c/build:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/edmonds/bin:/home/edmonds/.cargo/bin:/sbin:/bin:/usr/games" /usr/bin/protoc --cpp_out /tmp/protobuf-c/build -I/usr/include -I/tmp/protobuf-c /tmp/protobuf-c/protobuf-c/protobuf-c.proto
FAILED: CMakeFiles/protoc-generated-files protobuf-c/protobuf-c.pb.cc protobuf-c/protobuf-c.pb.h /tmp/protobuf-c/build/CMakeFiles/protoc-generated-files /tmp/protobuf-c/build/protobuf-c/protobuf-c.pb.cc /tmp/protobuf-c/build/protobuf-c/protobuf-c.pb.h
cd /tmp/protobuf-c/build && /usr/bin/cmake -E env PATH="/tmp/protobuf-c/build:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/edmonds/bin:/home/edmonds/.cargo/bin:/sbin:/bin:/usr/games" /usr/bin/protoc --cpp_out /tmp/protobuf-c/build -I/usr/include -I/tmp/protobuf-c /tmp/protobuf-c/protobuf-c/protobuf-c.proto
/tmp/protobuf-c/protobuf-c/protobuf-c.proto: Input is shadowed in the --proto_path by "/usr/include/protobuf-c/protobuf-c.proto". Either use the latter file as your input or reorder the --proto_path so that the former file's location comes first.
[2/19] /usr/bin/cc -DPACKAGE_STRING="\"protobuf-c 1.5.0\"" -DPACKAGE_VERSION=\"1.5.0\" -I/tmp/protobuf-c -I/tmp/protobuf-c/protobuf-c -I/tmp/protobuf-c/build -MD -MT CMakeFiles/protobuf-c.dir/tmp/protobuf-c/protobuf-c/protobuf-c.c.o -MF CMakeFiles/protobuf-c.dir/tmp/protobuf-c/protobuf-c/protobuf-c.c.o.d -o CMakeFiles/protobuf-c.dir/tmp/protobuf-c/protobuf-c/protobuf-c.c.o -c /tmp/protobuf-c/protobuf-c/protobuf-c.c
ninja: build stopped: subcommand failed.
protoc-gen-c requires protobuf-c.
Properly set protobuf-c BUILD_INTERFACE.
To support both <protobuf-c/protobuf-c.h> and "protobuf-c.h"
Signed-off-by: Clément Péron <peron.clem@gmail.com>
Some executable and library add header files as source.
These should not be declared as source file, remove them.
Signed-off-by: Clément Péron <peron.clem@gmail.com>
cxx-generate-packed-data needs to link with protobuf library for the C++
source file.
Use the protobuf::libprotobuf to get both library and include directory.
Signed-off-by: Clément Péron <peron.clem@gmail.com>
PROTOBUF_PROTOC_EXECUTABLE is not set in the Protobuf CMake config file.
Set it properly in case we use CMake protobuf config file.
Signed-off-by: Clément Péron <peron.clem@gmail.com>
The CMake module is used by default but isn't compatible with
recent protobuf version.
Try to first look for a protobuf config then fallback to legacy
cmake module.
Signed-off-by: Clément Péron <peron.clem@gmail.com>
The steps to add this functionality are from the cmake tutorial:
https://cmake.org/cmake/help/latest/guide/tutorial/index.html
The include directories being set on the targets is necessary
for dependent targets. There is some redundancy with the
INCLUDE_DIRECTORIES calls alreday present, but I left it alone
to make the PR smaller and more approachable.
The project currently uses mixed cases in functions. This uses
lowercase on calls I touched, as this is what CMake documentation
uses and seems to be the preferred way.
I also started wrapping long lines, as some of the lines I touched
were over 170 characters.
I tested this on both Mac OS 10.15 Catalina and CentOS 7 (with
devtoolset-7) with CMake 3.10.3.
Will work on tests in CI next.
A user of the protobuf-c library is confronted with MSVC warnings about missing
PDB if the library happens to be built/configured using the CMAKE_BUILD_TYPE
"Debug" or "RelWithDebInfo". This commit deals away with the warning by
installing the "protobuf-c.pdb" alongside the lib. The .pdb is installed only
if it exists. Configuring "Release" or building under Linux won't produce and
won't install the PDB.