Package: bob.example.cmake
Example project using Bob’s C++ interfaceThis example project shows a way to incorporate Bob’s C++ libraries into a C++ project.
For this, is uses theCMakeinterface, and a home-developedFindBob.cmakefile.
It relies on the python interface to download and installBob.
More information about the Bob installation can be found on itswebpage.This package is licensed under a BSD-3 license with a copyright of the Regents of the University of Colorado on behalf of the University of Colorado Colorado Springs.
Please see LICENSE file for details.Building this exampleAs the example requires someBobpackages to be installed, we first run one of the ways to installBob, i.e., usingbuildout.
For that, simply go to the main directory of this package and call:$ python bootstrap-buildout.py
$ ./bin/buildoutThis will checkout some of the packages to thesrcdirectory, and download some into theeggsdirectory.
If you have Bob installed globally, it will use the globally installed packages instead of downloading new eggs.
If you have Bob installed in a non-default directory, for example in anvirtual environment, you can use that python version to bootstrap.Inside of this package I have prepared a smallCMakeproject that includes some of theBobpackages.
It uses theFindBob.cmaketo locate Bob’s include directories and libraries.
To enable that, you can use thefind_package(Bob COMPONENTS <package(s)> REQUIRED)command to find the list of bobpackage(s).
Later, you can use threeCMakevariablesBob_INCLUDE_DIRS,Bob_LIBRARY_DIRS,Bob_LIBRARIESandBob_DEFINITIONSand add it to your project:cmake_minimum_required(VERSION 2.8)
project(test)

# Set the module path so that "FindBob.cmake" is found
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})

# Find all Bob packages recursively
find_package(Bob COMPONENTS bob.io.image REQUIRED)

# Add Bob's include directories
include_directories(${Bob_INCLUDE_DIRS})
# Add Bob's library directories
link_directories(${Bob_LIBRARY_DIRS})
# Add Bob's libraries
link_libraries(${Bob_LIBRARIES} boost_system)
# Add Bob's definitions
add_definitions(${Bob_DEFINITIONS})

# create an "my_test" executable from file "test.cpp"
add_executable(my_test test.cpp)For some reason (that I do not understand) we also need to add theboost_systemlibrary, although it should theoretically be linked to theBoblibraries already.So, now we can go ahead and compile our package usingCMake:$ mkdir build
$ cd build
$ cmake ..
$ makeand we should get an executablemy_testinside the build directory.
Note that you can pass a variable to CMake to use a customBobinstallation:$ cmake .. -DBOB_PREFIX_PATH=/path/to/your/bob/installationor set theBOB_PREFIX_PATHenvironment variable accordingly.
If you have a local directory containing (some of) the Bob packages insidesrcoreggssub-directories, you can set theBOB_SOURCE_DIRvariable, which defaults to the directory where theCMakeLists.txtis located:$ cmake .. -DBOB_SOURCE_DIR=/path/to/your/local/bob/packagesThe evaluation order of the directories is:${BOB_SOURCE_DIR}/src${BOB_SOURCE_DIR}/eggs${BOB_PREFIX_PATH}/lib/*/site-packages(where * typically is your python version)the system pathTo run the example, go back to the package base directory (otherwise it will not find the example image) and call:$ ./build/my_testThis should create an HDF5 file calledtest.hdf5inside the current directory.