带有CMakeLists的协议缓冲区

时间:2015-09-18 08:38:12

标签: cmake protocol-buffers

我的项目有srcinclude以及其父级胜利下的一些旧文件夹。我创建了一个名为proto的文件夹,其中包含VisionData.proto。我想生成预期的输出文件,但它不起作用。我查看了it的官方网站并做了他们在那里写的任何内容,但仍然没有运气。这是我的CMakeLists:

cmake_minimum_required(VERSION 2.8.3)
project(uwsim_imgproc)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
set_source_files_properties(${PROTO_SRC} ${PROTO_HEADER} PROPERTIES GENERATED TRUE)


find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  roscpp
  sensor_msgs
  std_msgs
  image_transport
)

find_package(OpenCV REQUIRED)
find_package(Protobuf REQUIRED)


catkin_package(
INCLUDE_DIRS include
LIBRARIES uwsim_imgproc filters
CATKIN_DEPENDS cv_bridge roscpp sensor_msgs std_msgs
#  DEPENDS system_lib
)


set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS} PARENT_SCOPE)
set(PROTOBUF_LIBRARIES ${PROTOBUF_LIBRARIES} PARENT_SCOPE)
set(PROTO_SRC ${PROTO_SRC} PARENT_SCOPE)
set(PROTO_HEADER ${PROTO_HEADER} PARENT_SCOPE)


PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS VisionData.proto)


include_directories(
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS} 
  ${PROTOBUF_INCLUDE_DIRS}
  ${CMAKE_CURRENT_BINARY_DIR}
  include
)

link_directories( 
  ${OpenCV_LINK_DIRS}
)

add_library(filters
        src/Obstacle.cpp
            src/HorizonDetector.cpp
            src/GenericTools.cpp
        src/Kalman.cpp
        src/HungarianAlg.cpp
        src/Ctracker.cpp
)

add_executable(cameraSubscriber src/main.cpp)
add_executable(VisionData VisionData.cc ${PROTO_SRCS} ${PROTO_HDRS})

add_dependencies(cameraSubscriber ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

target_link_libraries(VisionData 
${PROTOBUF_LIBRARIES}
)

target_link_libraries(filters
   ${OpenCV_LIBRARIES}
)

target_link_libraries(cameraSubscriber
   ${catkin_LIBRARIES}
   ${OpenCV_LIBRARIES}
   filters
 )

我得到的错误信息是:

CMake Error at uwsim_imgproc/CMakeLists.txt:60 (add_executable):
  Cannot find source file:

    VisionData.cc

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx

任何帮助都将不胜感激。

更新:

修复了错误的问题,但是,我的CMakeLists不生成应该生成的任何.h或.cc文件。

cmake_minimum_required(VERSION 2.8.3)
project(uwsim_imgproc)
include(FindProtobuf)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
set_source_files_properties(${PROTO_SRC} ${PROTO_HEADER} PROPERTIES GENERATED TRUE)


find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  roscpp
  sensor_msgs
  std_msgs
  image_transport
)

find_package(OpenCV REQUIRED)
find_package(Protobuf REQUIRED)


catkin_package(
INCLUDE_DIRS include
LIBRARIES uwsim_imgproc filters
CATKIN_DEPENDS cv_bridge roscpp sensor_msgs std_msgs
#  DEPENDS system_lib
)


set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS} PARENT_SCOPE)
set(PROTOBUF_LIBRARIES ${PROTOBUF_LIBRARIES} PARENT_SCOPE)
set(PROTO_SRC ${PROTO_SRC} PARENT_SCOPE)
set(PROTO_HEADER ${PROTO_HEADER} PARENT_SCOPE)


PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS proto/VisionData.proto)


include_directories(
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS} 
  ${PROTOBUF_INCLUDE_DIRS}
  ${CMAKE_CURRENT_BINARY_DIR}
  include
)

link_directories( 
  ${OpenCV_LINK_DIRS}
)

add_library(filters
        src/Obstacle.cpp
            src/HorizonDetector.cpp
            src/GenericTools.cpp
        src/Kalman.cpp
        src/HungarianAlg.cpp
        src/Ctracker.cpp
)

add_executable(cameraSubscriber src/main.cpp ${PROTO_SRCS} ${PROTO_HDRS})

add_dependencies(cameraSubscriber ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

target_link_libraries(cameraSubscriber 
${PROTOBUF_LIBRARIES}
)

target_link_libraries(filters
   ${OpenCV_LIBRARIES}
)

target_link_libraries(cameraSubscriber
   ${catkin_LIBRARIES}
   ${OpenCV_LIBRARIES}
   filters
 )

1 个答案:

答案 0 :(得分:0)

class MyTextEdit:protected QTextEdit{ void focusInEvent(); }; QTextEdit* myTextEdit=new MyTextEdit(); 生成的源文件的名称最终在 function your-themme_html_head_alter(&$head_elements) { $remove = array( 'apple-touch-icon57', 'apple-touch-icon72', 'apple-touch-icon114' ); foreach ($remove as $key) { if (isset($head_elements[$key])) { unset($head_elements[$key]); } } //add $appleIcon57px = array('#tag' => 'link', '#type' => 'html_tag', '#attributes' => array('rel' => 'apple-touch-icon', 'href' => '/misc/AMU-NUMERIQUE-ICONE-57.png', 'type' => 'image/png', 'media' => 'screen and (resolution: 163dpi)'),); $appleIcon72px = array('#tag' => 'link','#type' => 'html_tag', '#attributes' => array('rel' => 'apple-touch-icon', 'href' => '/misc/AMU-NUMERIQUE-ICONE-72.png', 'type' => 'image/png', 'media' => 'screen and (resolution: 132dpi)'),); $appleIcon114px = array('#tag' => 'link','#type' => 'html_tag', '#attributes' => array('rel' => 'apple-touch-icon', 'href' => '/misc/AMU-NUMERIQUE-ICONE-114.png', 'type' => 'image/png', 'media' => 'screen and (resolution: 326dpi)'),); $head_elements['apple-touch-icon57']=$appleIcon57px; $head_elements['apple-touch-icon72']=$appleIcon72px; $head_elements['apple-touch-icon114']=$appleIcon114px; }

  1. 此文件可能会在protobuf_generate_cpp()中生成(因为它的CMake策略不会在源目录中生成文件)。

  2. 此文件可能遵循一些您不必了解的内部命名方案。

  3. 所以你的行......

    PROTO_SRCS

    ......可能不应该有CMAKE_BINARY_DIR