blob: b54683573ca0c40cbcaed6bd8c4b230d95819ff5 [file] [log] [blame]
Marat Dukhan2dbdc2f2019-10-08 16:36:23 -07001#!/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
9set -e
10
11mkdir -p build/local
12
13CMAKE_ARGS=()
14
15# CMake-level configuration
16CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release")
17CMAKE_ARGS+=("-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
18
19# If Ninja is installed, prefer it to Make
20if [ -x "$(command -v ninja)" ]
21then
22 CMAKE_ARGS+=("-GNinja")
23fi
24
25CMAKE_ARGS+=("-DXNNPACK_LIBRARY_TYPE=static")
26
27CMAKE_ARGS+=("-DXNNPACK_BUILD_BENCHMARKS=ON")
28CMAKE_ARGS+=("-DXNNPACK_BUILD_TESTS=ON")
29
30# Use-specified CMake arguments go last to allow overridding defaults
31CMAKE_ARGS+=($@)
32
33cd build/local && cmake ../.. \
34 "${CMAKE_ARGS[@]}"
35
36# Cross-platform parallel build
37if [ "$(uname)" == "Darwin" ]
38then
39 cmake --build . -- "-j$(sysctl -n hw.ncpu)"
40else
41 cmake --build . -- "-j$(nproc)"
42fi