1#!/usr/bin/env bash 2# 3# Copyright (c) 2008-2017 the Urho3D project. 4# 5# Permission is hereby granted, free of charge, to any person obtaining a copy 6# of this software and associated documentation files (the "Software"), to deal 7# in the Software without restriction, including without limitation the rights 8# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9# copies of the Software, and to permit persons to whom the Software is 10# furnished to do so, subject to the following conditions: 11# 12# The above copyright notice and this permission notice shall be included in 13# all copies or substantial portions of the Software. 14# 15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21# THE SOFTWARE. 22# 23 24# Determine source tree and build tree 25if [[ "$1" ]] && [[ ! "$1" =~ ^- ]]; then BUILD=$1; shift; elif [[ -f $(pwd)/CMakeCache.txt ]]; then BUILD=$(pwd); else caller=$(ps -o args= $PPID |cut -d' ' -f2); if [[ ! "$caller" =~ cmake_.*\.sh$ ]]; then caller=$0; fi; echo "Usage: ${caller##*/} /path/to/build-tree [build-options]"; exit 1; fi 26SOURCE=$(cd ${0%/*}; pwd) 27if [[ "$BUILD" == "." ]]; then BUILD=$(pwd); fi 28 29# Define helpers 30. "$SOURCE"/.bash_helpers.sh 31 32# Detect CMake toolchains directory if it is not provided explicitly 33[ "$TOOLCHAINS" == "" ] && TOOLCHAINS="$SOURCE"/CMake/Toolchains 34[ ! -d "$TOOLCHAINS" -a -d "$URHO3D_HOME"/share/Urho3D/CMake/Toolchains ] && TOOLCHAINS="$URHO3D_HOME"/share/Urho3D/CMake/Toolchains 35 36# Default to native generator and toolchain if none is specified explicitly 37IFS=# 38OPTS= 39for a in $@; do 40 case $a in 41 --fix-scm) 42 FIX_SCM=1 43 ;; 44 Eclipse\ CDT4\ -\ Unix\ Makefiles) 45 ECLIPSE=1 46 ;; 47 -DIOS=1) 48 IOS=1 49 ;; 50 -DTVOS=1) 51 TVOS=1 52 ;; 53 -DANDROID=1) 54 ANDROID=1 && OPTS="-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/Android.cmake" 55 ;; 56 -DRPI=1) 57 if [[ ! $(uname -m) =~ ^arm ]]; then OPTS="-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/RaspberryPi.cmake"; fi 58 ;; 59 -DARM=1) 60 if [[ ! $(uname -m) =~ ^(arm|aarch64) ]]; then OPTS="-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/Arm.cmake"; fi 61 ;; 62 -DWIN32=1) 63 OPTS="-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/MinGW.cmake" 64 ;; 65 -DWEB=1) 66 OPTS="-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/Emscripten.cmake" 67 ;; 68 esac 69done 70 71# Create project with the chosen CMake generator and toolchain 72cmake -E make_directory "$BUILD" && cmake -E chdir "$BUILD" cmake $OPTS $@ "$SOURCE" && post_cmake 73 74# vi: set ts=4 sw=4 expandtab: 75