cmake_generic.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2008-2020 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. # Determine source tree and build tree
  24. if [[ "$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
  25. SOURCE=$(cd ${0%/*}/..; pwd)
  26. if [[ "$BUILD" == "." ]]; then BUILD=$(pwd); fi
  27. # Define helpers
  28. . "$SOURCE"/script/.bash_helpers.sh
  29. # Detect CMake toolchains directory if it is not provided explicitly
  30. [ "$TOOLCHAINS" == "" ] && TOOLCHAINS="$SOURCE"/CMake/Toolchains
  31. [ ! -d "$TOOLCHAINS" -a -d "$URHO3D_HOME"/share/Urho3D/CMake/Toolchains ] && TOOLCHAINS="$URHO3D_HOME"/share/Urho3D/CMake/Toolchains
  32. # Default to native generator and toolchain if none is specified explicitly
  33. IFS=#
  34. OPTS=
  35. for a in $@; do
  36. case $a in
  37. --fix-scm)
  38. FIX_SCM=1
  39. ;;
  40. Eclipse\ CDT4\ -\ Unix\ Makefiles)
  41. ECLIPSE=1
  42. ;;
  43. -DIOS=1)
  44. IOS=1
  45. ;;
  46. -DTVOS=1)
  47. TVOS=1
  48. ;;
  49. -DANDROID=1)
  50. echo For Android platform, use Gradle build system instead of invoking CMake build system directly!
  51. exit 1
  52. ;;
  53. -DRPI=1)
  54. if [[ ! $(uname -m) =~ ^arm ]]; then OPTS="-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/RaspberryPi.cmake"; fi
  55. ;;
  56. -DARM=1)
  57. if [[ ! $(uname -m) =~ ^(arm|aarch64) ]]; then OPTS="-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/Arm.cmake"; fi
  58. ;;
  59. -DMINGW=1)
  60. OPTS="-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/MinGW.cmake"
  61. ;;
  62. -DWEB=1)
  63. OPTS="-DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/Emscripten.cmake"
  64. ;;
  65. esac
  66. done
  67. # Create project with the chosen CMake generator and toolchain
  68. cmake -E make_directory "$BUILD" && cmake -E chdir "$BUILD" cmake $OPTS $@ "$SOURCE" && post_cmake
  69. # vi: set ts=4 sw=4 expandtab: