| ############################################################################## |
| # Example command to build Caffe2 |
| ############################################################################## |
| CAFFE2_ROOT="$( cd "$(dirname "$0")"/.. ; pwd -P)" |
| echo "Caffe2 codebase root is: $CAFFE2_ROOT" |
| # Build protobuf compiler from third_party if configured to do so |
| if [ -n "${USE_HOST_PROTOC:-}" ]; then |
| echo "Building protoc before compiling Caffe2..." |
| $CAFFE2_ROOT/scripts/build_host_protoc.sh || exit 1 |
| CMAKE_ARGS="$CMAKE_ARGS \ |
| -DCAFFE2_CUSTOM_PROTOC_EXECUTABLE=$CAFFE2_ROOT/build_host_protoc/bin/protoc" |
| # We are going to build the target into build. |
| BUILD_ROOT="$CAFFE2_ROOT/build" |
| echo "Building Caffe2 in: $BUILD_ROOT" |
| # Now, actually build the target. |
| cmake .. ${CMAKE_ARGS} "$@" || exit 1 |
| if [ "$(uname)" = 'Darwin' ]; then |
| cmake --build . -- "-j$(sysctl -n hw.ncpu)" |
| cmake --build . -- "-j$(nproc)" |