Ich habe die Protokollpufferquelle von GitHub heruntergeladen. Ich möchte es nicht global installieren und möchte es nur in meinem ROS-Paket verwenden. Ich fand cmake
Dateien here aber nicht sicher, wie man sie in meinem Projekt verwendet.Konfigurieren Sie CMakeLists.txt für lokal installierte Protokollpuffer
Unten ist der Inhalt meiner CMakeLists.txt
:
cmake_minimum_required(VERSION 2.8.3)
project(local_protobuf_ros_example)
find_package(catkin REQUIRED COMPONENTS roscpp)
find_package(Protobuf REQUIRED)
catkin_package()
include_directories(include ${catkin_INCLUDE_DIRS} ${PROTOBUF_INCLUDE_DIRS})
add_library(addressbook_protobuf include/addressbook.pb.cc)
add_executable(main src/main.cpp)
target_link_libraries(main ${catkin_LIBRARIES} addressbook_protobuf ${PROTOBUF_LIBRARIES})
Im Folgenden finden Sie die Dateistruktur von ROS Paket:
├── CMakeLists.txt
├── include
│ ├── addressbook.pb.cc
│ ├── addressbook.pb.h
│ └── addressbook.proto
├── lib
│ ├── protobuf-3.5.0
│ │ ├── cmake
│ │ │ ├── CMakeLists.txt
│ │ │ ├── examples.cmake
│ │ │ ├── extract_includes.bat.in
│ │ │ ├── install.cmake
│ │ │ ├── libprotobuf.cmake
│ │ │ ├── libprotobuf-lite.cmake
│ │ │ ├── libprotoc.cmake
│ │ │ ├── protobuf-config.cmake.in
│ │ │ ├── protobuf-config-version.cmake.in
│ │ │ ├── protobuf-lite.pc.cmake
│ │ │ ├── protobuf-module.cmake.in
│ │ │ ├── protobuf-options.cmake
│ │ │ ├── protobuf.pc.cmake
│ │ │ ├── protoc.cmake
│ │ │ ├── README.md
│ │ │ └── tests.cmake
│ │ ├──SOME_FILES_ARE_NOT_BEING_SHOWN_HERE
│ └── protobuf-cpp-3.5.0.zip
├── package.xml
└── src
└── main.cpp
Ich möchte wissen, dass, wie oben CMakeLists.txt
so konfigurieren, dass es verwendet lokal installierte Protokollpuffer?
Was nicht funktioniert, 'find_package (Protobuf ERFORDERLICH)' kehrt Fehler? Sehen Sie sich den [Satz möglicher Installationspräfixe für das Paket an] (https://cmake.org/cmake/help/v3.0/command/find_package.html) – Ptaq666
@ Ptaq666: Es scheint, dass 'find_package (Protobuf REQUIRED)' zeigt auf Systemstandardprotokollpuffer, was eine alte Version ist. Ich habe die neue Version, aber ich weiß nicht, wie man 'find_package (Protobuf REQUIRED)' konfiguriert, um auf diese Version zu zeigen. –
In 'find_package' können Sie auch die Version des Pakets angeben - zusammen mit der Antwort von @piwi sollte dies das Problem lösen. – Ptaq666