Marat Dukhan | 2dbdc2f | 2019-10-08 16:36:23 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (c) Facebook, Inc. and its affiliates. |
| 4 | # All rights reserved. |
| 5 | # |
| 6 | # This source code is licensed under the BSD-style license found in the |
| 7 | # LICENSE file in the root directory of this source tree. |
| 8 | |
| 9 | set -e |
| 10 | |
| 11 | mkdir -p build/local |
| 12 | |
| 13 | CMAKE_ARGS=() |
| 14 | |
| 15 | # CMake-level configuration |
| 16 | CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release") |
| 17 | CMAKE_ARGS+=("-DCMAKE_POSITION_INDEPENDENT_CODE=ON") |
| 18 | |
| 19 | # If Ninja is installed, prefer it to Make |
| 20 | if [ -x "$(command -v ninja)" ] |
| 21 | then |
| 22 | CMAKE_ARGS+=("-GNinja") |
| 23 | fi |
| 24 | |
| 25 | CMAKE_ARGS+=("-DXNNPACK_LIBRARY_TYPE=static") |
| 26 | |
| 27 | CMAKE_ARGS+=("-DXNNPACK_BUILD_BENCHMARKS=ON") |
| 28 | CMAKE_ARGS+=("-DXNNPACK_BUILD_TESTS=ON") |
| 29 | |
| 30 | # Use-specified CMake arguments go last to allow overridding defaults |
| 31 | CMAKE_ARGS+=($@) |
| 32 | |
| 33 | cd build/local && cmake ../.. \ |
| 34 | "${CMAKE_ARGS[@]}" |
| 35 | |
| 36 | # Cross-platform parallel build |
| 37 | if [ "$(uname)" == "Darwin" ] |
| 38 | then |
| 39 | cmake --build . -- "-j$(sysctl -n hw.ncpu)" |
| 40 | else |
| 41 | cmake --build . -- "-j$(nproc)" |
| 42 | fi |