All right, here is what I did. I feel like it is tremendously hacky, but it appears to work.
I created a cmake_modules/Findtrunk.cmake
file containing:
#invented based on what I found in libfreenect/cmake_modules/Findlibusb-1.0.cmake
if (TRUNK_DIR)
# in cache already
set(TRUNK_FOUND TRUE)
else (TRUNK_DIR)
find_path(TRUNK_DIR
NAMES
rcp/Makefile
PATHS
$ENV{HOME}/src/hai/trunk
)
if (TRUNK_DIR)
set(TRUNK_FOUND TRUE)
endif (TRUNK_DIR)
if (TRUNK_FOUND)
if (NOT trunk_FIND_QUIETLY)
message(STATUS "Found trunk:")
message(STATUS " - ${TRUNK_DIR}")
endif (NOT trunk_FIND_QUIETLY)
else (TRUNK_FOUND)
if (trunk_FIND_REQUIRED)
message(FATAL_ERROR "Could not find trunk")
endif (trunk_FIND_REQUIRED)
endif (TRUNK_FOUND)
endif (TRUNK_DIR)
I added the following 2 snippets to my CMakeLists.txt
file:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
find_package(trunk REQUIRED)
and
include_directories(
${catkin_INCLUDE_DIRS}
${TRUNK_DIR}/common/include
${TRUNK_DIR}/this/that
${TRUNK_DIR}/the/other/thing
)
set(BBR_FILES
${TRUNK_DIR}/this/that/buffer.c
${TRUNK_DIR}/this/that/config.c
)
set_source_files_properties(${BBR_FILES} PROPERTIES LANGUAGE CXX)
add_executable(mp2ros_node
src/mp2ros_node.cpp
${BBR_FILES}
)
and that seems to work. I'm not sure it's the most straightforward thing to do. I like the idea of creating a Findtrunk.cmake
file so that others on my team might edit it to reflect the location of their trunk
directory. We'll see if that ever comes to pass.
I would appreciate any questions, comments, or snide remarks more experienced folks would care to make regarding this approach. I'm certain that I'm not following any number of standard Cmake conventions (I noticed that other Findxxx.cmake files define INCLUDE_XXX_DIRS, for example), but this seems to work for me so far.
Do the external projects use cmake? If they provide a cmake config file, you can find_package them just like opencv: http://wiki.ros.org/vision_opencv
Unfortunately, it does not. It is a traditional Make based project. I would like to pull a few header files and source files from that project into mine.
So far, I have started down the path of writing my own "Findtrunk.cmake" file to find the project in my source tree (which I keep separate from my budding ROS source tree... for the moment) ,defining ${TRUNK_DIR} in Findtrunk.cmake, and adding ${TRUNK_DIR}/include to include_directories().