cmake_android.bat 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ::
  2. :: Copyright (c) 2008-2013 the Urho3D project.
  3. ::
  4. :: Permission is hereby granted, free of charge, to any person obtaining a copy
  5. :: of this software and associated documentation files (the "Software"), to deal
  6. :: in the Software without restriction, including without limitation the rights
  7. :: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. :: copies of the Software, and to permit persons to whom the Software is
  9. :: furnished to do so, subject to the following conditions:
  10. ::
  11. :: The above copyright notice and this permission notice shall be included in
  12. :: all copies or substantial portions of the Software.
  13. ::
  14. :: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. :: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. :: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. :: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. :: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. :: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. :: THE SOFTWARE.
  21. ::
  22. @echo off
  23. pushd %~dp0
  24. :: Define USE_MKLINK to 1 to enable out-of-source build and symbolic linking of resources from Bin directory
  25. set "build=Source\Android"
  26. set "source=.."
  27. set "use_mklink="
  28. if exist android-Build\CMakeCache.txt. for /F "eol=/ delims=:= tokens=1-3" %%i in (android-Build\CMakeCache.txt) do if "%%i" == "USE_MKLINK" set "use_mklink=%%k"
  29. :loop
  30. if not "%1" == "" (
  31. if "%1" == "-DUSE_MKLINK" set "use_mklink=%~2"
  32. shift
  33. shift
  34. goto loop
  35. )
  36. if "%use_mklink%" == "1" (
  37. :: Remove cache file from opposite build directory
  38. if exist Source\Android\CMakeCache.txt. del /F Source\Android\CMakeCache.txt
  39. if exist Source\Android\CMakeFiles. rd /S /Q Source\Android\CMakeFiles
  40. cmake -E make_directory android-Build
  41. set "build=android-Build"
  42. set "source=..\Source"
  43. for %%d in (CoreData Data) do if not exist "Source\Android\assets\%%d". mklink /D "Source\Android\assets\%%d" "..\..\..\Bin\%%d"
  44. for %%d in (src res assets) do if not exist "android-Build\%%d". mklink /D "android-Build\%%d" "..\Source\Android\%%d"
  45. for %%f in (AndroidManifest.xml build.xml) do if not exist "android-Build\%%f". mklink "android-Build\%%f" "..\Source\Android\%%f"
  46. ) else (
  47. if exist android-Build\CMakeCache.txt. del /F android-Build\CMakeCache.txt
  48. if exist android-Build\CMakeFiles. rd /S /Q android-Build\CMakeFiles
  49. )
  50. echo on
  51. :: \todo suppress policy warning (for 2.8.12 early adopters), remove this option when CMake minimum version is 2.8.12
  52. set "OPT=-Wno-dev"
  53. cmake -E chdir %build% cmake %OPT% -G "Unix Makefiles" -DANDROID=1 -DCMAKE_TOOLCHAIN_FILE=%source%\CMake\Toolchains\android.toolchain.cmake -DLIBRARY_OUTPUT_PATH_ROOT=. %* %source%
  54. @popd