Including header file in CMakeLists
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}
)
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.