Build and configuration¶
xtensor build supports the following options:
BUILD_TESTS: enables the
xbenchmarktargets (see below).
gtestand builds it locally instead of using a binary installation.
GTEST_SRC_DIR: indicates where to find the
gtestsources instead of downloading them.
XTENSOR_ENABLE_ASSERT: activates the assertions in
XTENSOR_CHECK_DIMENSION: turns on
XTENSOR_ENABLE_ASSERTand activates dimensions check in
xtensor. Note that the dimensions check should not be activated if you expect
operator()to perform broadcasting.
All these options are disabled by default. Enabling
DOWNLOAD_GTEST or setting
BUILD_TESTS option is enabled, the following targets are available:
- xtest: builds an run the test suite.
- xbenchmark: builds and runs the benchmarks.
For instance, building the test suite of
xtensor with assertions enabled:
mkdir build cd build cmake -DBUILD_TESTS=ON -DXTENSOR_ENABLE_ASSERT=ON ../ make xtest
Building the test suite of
xtensor where the sources of
gtest are located in e.g.
mkdir build cd build cmake -DGTEST_SRC_DIR=/usr/share/gtest ../ make xtest
xtensor can be configured via macros, which must be defined before including any of its header. Here is a list of
XTENSOR_ENABLE_ASSERT: enables assertions in xtensor, such as bound check.
DEFAULT_DATA_CONTAINER(T, A): defines the type used as the default data container for tensors and arrays.
value_typeof the container and
DEFAULT_SHAPE_CONTAINER(T, EA, SA): defines the type used as the default shape container for tensors and arrays.
value_typeof the data container,
allocator_typeof the shape container.
DEFAULT_LAYOUT: defines the default layout (row_major, column_major, dynamic) for tensors and arrays. We strongly discourage using this macro, which is provided for testing purpose. Prefer defining alias types on tensor and array containers instead.