catkin_make不会编译我的包..但是

时间:2016-11-30 01:16:10

标签: c++ ros pugixml catkin

我目前遇到问题,如果catkin_make我的catkin_workspace我的包不会编译标题。

但如果我catkin_make --only-pkg-with-deps packakge它运作正常吗?

那么为什么我能够编译,如果只编译那个独立于其余的,但是当我编译所有内容时它将找不到头文件?

这是树结构:

pkg_a/
    ├── CMakeLists.txt
    ├── include
    │   └── pkg_a
    │       ├── pugiconfig.hpp
    │       └── pugixml.hpp
    ├── package.xml
    ├── src
        ├── src.cpp
        ├── header_to_src.h
        ├── node.cpp
        ├── pugixml.cpp
        ├── src_2.cpp
        └── header_to_src_2.h

我无法编译的标题是内部包含的标题。 pugixml.cpp找不到pugixml.hpp ..

它包含在#include <pkg_a/pugixml.hpp>

CMakeList:

cmake_minimum_required(VERSION 2.8.3)
project(pkg_a)

#Compiler flags
add_definitions(-std=c++1y)
find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  genmsg
  message_generation
  depend_1
  depend_2
)


catkin_package(
   INCLUDE_DIRS include
   LIBRARIES ${PROJECT_NAME}
   CATKIN_DEPENDS
   DEPENDS system_lib

)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

## Mark cpp header files for installation
 install(DIRECTORY include/${PROJECT_NAME}/
   DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
   FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
   PATTERN ".svn" EXCLUDE
 )

## Mark other files for installation (e.g. launch and bag files, etc.)
 install(
     DIRECTORY include/${PROJECT_NAME}/
#   # myfile1
#   # myfile2
   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
 )

SET(SRC_FILES
        ${SRC_FILES}
        ${CMAKE_CURRENT_SOURCE_DIR}/src/src.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/src_2.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/pugixml.cpp
#       ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
        CACHE INTERNAL ""
)

add_library(${PROJECT_NAME} ${SRC_FILES})

add_executable(run_${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/node.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/pugixml.cpp)
add_dependencies( ${PROJECT_NAME} depend_1_generate_messages_cpp depend_2_generate_message_cpp )
target_link_libraries(run_${PROJECT_NAME}
    ${PROJECT_NAME}
    ${catkin_LIBRARIES}
)

0 个答案:

没有答案