cmake_gcc.sh 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2008-2014 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. # Ensure we are in project root directory
  24. cd $( dirname $0 )
  25. SOURCE=`pwd`/Source
  26. # Define helpers
  27. . ./.bash_helpers.sh
  28. # Detect CMake toolchains directory if it is not provided explicitly
  29. [ "$TOOLCHAINS" == "" ] && TOOLCHAINS=$SOURCE/CMake/Toolchains
  30. [ ! -d $TOOLCHAINS -a -d $URHO3D_HOME/Source/CMake/Toolchains ] && TOOLCHAINS=$URHO3D_HOME/Source/CMake/Toolchains
  31. [ ! -d $TOOLCHAINS -a -d $CMAKE_PREFIX_PATH/share/Urho3D/CMake/Toolchains ] && TOOLCHAINS=$CMAKE_PREFIX_PATH/share/Urho3D/CMake/Toolchains
  32. # Add support for Eclipse IDE
  33. IFS=#
  34. GENERATOR="Unix Makefiles"
  35. [[ $1 =~ ^eclipse$ ]] && GENERATOR="Eclipse CDT4 - Unix Makefiles" && shift && xmlstarlet --version >/dev/null 2>&1 && HAS_XMLSTARLET=1
  36. # Add support for CodeBlocks IDE
  37. [[ $1 =~ ^codeblocks$ ]] && GENERATOR="CodeBlocks - Unix Makefiles"
  38. # Add support for both native and cross-compiling build for Raspberry Pi
  39. [[ $( uname -m ) =~ ^armv6 ]] && PLATFORM="-DRASPI=1"
  40. # Create project with the respective CMake generators
  41. OPT=
  42. [ $ANDROID_NDK ] && msg "Android build" && cmake -E make_directory android-Build && cmake -E chdir android-Build cmake $OPT -G $GENERATOR -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/android.toolchain.cmake $@ $SOURCE && post_cmake android-Build
  43. [ $RASPI_TOOL ] && msg "Raspberry Pi build" && cmake -E make_directory raspi-Build && cmake -E chdir raspi-Build cmake $OPT -G $GENERATOR -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/raspberrypi.toolchain.cmake $@ $SOURCE && post_cmake raspi-Build
  44. [ $MINGW_PREFIX ] && msg "MinGW build" && cmake -E make_directory mingw-Build && cmake -E chdir mingw-Build cmake $OPT -G $GENERATOR -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/mingw.toolchain.cmake $@ $SOURCE && post_cmake mingw-Build
  45. [ ! $SKIP_NATIVE ] && msg "Native build" && cmake -E make_directory Build && cmake -E chdir Build cmake $OPT -G $GENERATOR $PLATFORM $@ $SOURCE && post_cmake Build
  46. unset IFS
  47. # Create symbolic links in the build directories
  48. if [ $ANDROID_NDK ]; then
  49. for dir in CoreData Data; do
  50. cmake -E create_symlink ../../../Bin/$dir Source/Android/assets/$dir
  51. done
  52. for f in AndroidManifest.xml build.xml src res assets jni; do
  53. if [ -e Source/Android/$f ]; then cmake -E create_symlink ../Source/Android/$f android-Build/$f; fi
  54. done
  55. fi
  56. exit 0
  57. # vi: set ts=4 sw=4 expandtab: