cmake_generic.bat 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ::
  2. :: Copyright (c) 2008-2015 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. :: Determine source tree and build tree
  24. set "SOURCE=%~dp0"
  25. set "BUILD="
  26. if "%~1" == "" goto :continue
  27. set "ARG1=%~1"
  28. if "%ARG1:~0,1%" equ "-" goto :continue
  29. set "BUILD=%~1"
  30. shift
  31. :continue
  32. if "%BUILD%" == "" if exist "%cd%\CMakeCache.txt" (set "BUILD=%cd%") else (goto :error)
  33. :: Detect CMake toolchains directory if it is not provided explicitly
  34. if "%TOOLCHAINS%" == "" set "TOOLCHAINS=%SOURCE%/CMake/Toolchains"
  35. if not exist "%TOOLCHAINS%" if exist "%URHO3D_HOME%/share/Urho3D/CMake/Toolchains" set "TOOLCHAINS=%URHO3D_HOME%/share/Urho3D/CMake/Toolchains"
  36. :: BEWARE that the TOOLCHAINS variable leaks to caller's environment!
  37. :: Default to native generator and toolchain if none is specified explicitly
  38. set "OPTS="
  39. set "arch="
  40. if exist "%BUILD%\CMakeCache.txt" for /F "eol=/ delims=:= tokens=1-3" %%i in (%BUILD%\CMakeCache.txt) do if "%%i" == "URHO3D_64BIT" if "%%k" == "1" set "arch= Win64"
  41. :loop
  42. if not "%~1" == "" (
  43. if "%~1" == "-DANDROID" if "%~2" == "1" set "OPTS=-G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=%TOOLCHAINS%\android.toolchain.cmake"
  44. if "%~1" == "-DEMSCRIPTEN" if "%~2" == "1" set "OPTS=-G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=%TOOLCHAINS%\emscripten.toolchain.cmake"
  45. if "%~1" == "-DURHO3D_64BIT" if "%~2" == "1" set "arch= Win64"
  46. if "%~1" == "-DURHO3D_64BIT" if "%~2" == "0" set "arch="
  47. if "%~1" == "-VS" set "OPTS=-G "Visual Studio %~2%arch%""
  48. shift
  49. shift
  50. goto loop
  51. )
  52. :: Create project with the chosen CMake generator and toolchain
  53. cmake -E make_directory %BUILD% && cmake -E chdir %BUILD% cmake %OPTS% %* %SOURCE%
  54. goto :eof
  55. :error
  56. echo Usage: %~nx0 \path\to\build-tree [build-options]
  57. exit /B 1
  58. :eof