Skip to main content
http://travis-ci.org/bioidiap/bob.example.cmake.svg?branch=v1.0.1 https://img.shields.io/badge/github-master-0000c0.png

Example project using Bob’s C++ interface

This example project shows a way to incorporate Bob’s C++ libraries into a C++ project. For this, is uses the CMake interface, and a home-developed FindBob.cmake file. It relies on the python interface to download and install Bob. More information about the Bob installation can be found on its webpage.

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 example

As the example requires some Bob packages to be installed, we first run one of the ways to install Bob, i.e., using buildout. For that, simply go to the main directory of this package and call:

$ python bootstrap-buildout.py
$ ./bin/buildout

This will checkout some of the packages to the src directory, and download some into the eggs directory. 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 an virtual environment, you can use that python version to bootstrap.

Inside of this package I have prepared a small CMake project that includes some of the Bob packages. It uses the FindBob.cmake to locate Bob’s include directories and libraries. To enable that, you can use the find_package(Bob COMPONENTS <package(s)> REQUIRED) command to find the list of bob package(s). Later, you can use three CMake variables Bob_INCLUDE_DIRS, Bob_LIBRARY_DIRS, Bob_LIBRARIES and Bob_DEFINITIONS and 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 the boost_system library, although it should theoretically be linked to the Bob libraries already.

So, now we can go ahead and compile our package using CMake:

$ mkdir build
$ cd build
$ cmake ..
$ make

and we should get an executable my_test inside the build directory. Note that you can pass a variable to CMake to use a custom Bob installation:

$ cmake .. -DBOB_PREFIX_PATH=/path/to/your/bob/installation

or set the BOB_PREFIX_PATH environment variable accordingly. If you have a local directory containing (some of) the Bob packages inside src or eggs sub-directories, you can set the BOB_SOURCE_DIR variable, which defaults to the directory where the CMakeLists.txt is located:

$ cmake .. -DBOB_SOURCE_DIR=/path/to/your/local/bob/packages

The evaluation order of the directories is:

  1. ${BOB_SOURCE_DIR}/src

  2. ${BOB_SOURCE_DIR}/eggs

  3. ${BOB_PREFIX_PATH}/lib/*/site-packages (where * typically is your python version)

  4. the system path

To run the example, go back to the package base directory (otherwise it will not find the example image) and call:

$ ./build/my_test

This should create an HDF5 file called test.hdf5 inside the current directory.

Release files for bob.example.cmake 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bob.example.cmake 1.0.1
File Size Uploaded
bob.example.cmake-1.0.1.zip 539.1 kB Details

Release files / bob.example.cmake-1.0.1.zip

Download URL bob.example.cmake-1.0.1.zip
Size 539.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f4e7580bebc0bfdc60a57d30cee4d5e1592bd43fed2a0c2c3aa22fc4878e03b5
BLAKE2b-256 checksum
How to use checksums
69b23227d9855340ad7164a89ea99ea58f0862229ce526f01cc505729ac2f5dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page