Ask Your Question
0

Including header file in CMakeLists

asked 2019-05-10 04:38:49 -0600

EdwardNur gravatar image

I have a header file that I want to include in my main function and use its classes and functions but how do I include in my CMakeLists? Basically, I am first writing this header file and I want to periodically compile it to see if any mistakes have been done before proceeding further

Here is my CMakeLists and I want to compile and check factorgraph.h:

cmake_minimum_required(VERSION 2.8.3)
project(gslam)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
            roscpp

)

catkin_package(
   INCLUDE_DIRS
        include
   CATKIN_DEPENDS
        roscpp
   LIBRARIES
        factorgraph  

)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

find_package(GTSAMCMakeTools)
# Find GTSAM components
find_package(GTSAM REQUIRED) # Uses installed package
include_directories(${GTSAM_INCLUDE_DIR})



install(DIRECTORY include/${PROJECT_NAME}/
        DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
        FILES_MATCHING PATTERN "*.h"
        PATTERN ".svn" EXCLUDE)

add_library(factorgraph  
     factorgraph.h  
)  
target_link_libraries(factorgraph
  ${catkin_LIBRARIES}
)
edit retag flag offensive close merge delete

Comments

2

I'd recommend to post this sort of question (ie: "how do I do X with CMake?") on more appropriate forums such as Stack Overflow, Ask Ubuntu or perhaps even the CMake support fora.

gvdhoorn gravatar imagegvdhoorn ( 2019-05-10 08:49:17 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-05-10 08:48:25 -0600

gvdhoorn gravatar image

This is not really a ROS question, but a CMake one.

In any case: you cannot compile a C++ header. Only source files.

You could #include your header in a dummy source file though. Then add a target compiling your dummy .cpp file.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-05-10 04:38:49 -0600

Seen: 75 times

Last updated: May 10