2 REM This batch file does an out-of-source CMake build in ../build_windows
3 REM This is for users who like to configure & build Blender with a single command.
5 setlocal ENABLEEXTENSIONS
7 set BUILD_DIR=%BLENDER_DIR%..\build_windows
11 REM Detect MSVC Installation
12 if DEFINED VisualStudioVersion goto msvc_detect_finally
13 set VALUE_NAME=ProductDir
15 set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\Setup\VC"
16 for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO set MSVC_VC_DIR=%%C
17 if DEFINED MSVC_VC_DIR goto msvc_detect_finally
19 set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\12.0\Setup\VC"
20 for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO set MSVC_VC_DIR=%%C
21 if DEFINED MSVC_VC_DIR goto msvc_detect_finally
23 if DEFINED MSVC_VC_DIR call "%MSVC_VC_DIR%\vcvarsall.bat"
28 if %ERRORLEVEL% NEQ 0 (
29 echo Error: "MSBuild" command not in the PATH.
30 echo You must have MSVC installed and run this from the "Developer Command Prompt"
31 echo ^(available from Visual Studio's Start menu entry^), aborting!
35 if %ERRORLEVEL% NEQ 0 (
36 echo Error: "CMake" command not in the PATH.
37 echo You must have CMake installed and added to your PATH, aborting!
40 if NOT EXIST %BLENDER_DIR%..\lib\nul (
41 echo Error: Path to libraries not found "%BLENDER_DIR%..\lib\"
42 echo This is needed for building, aborting!
53 echo Convenience targets
61 echo Utilities ^(not associated with building^)
69 set BUILD_DIR=%BUILD_DIR%_debug
72 REM Build Configurations
73 ) else if "%1" == "full" (
74 set BUILD_DIR=%BUILD_DIR%_full
75 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
76 -C"%BLENDER_DIR%\build_files\cmake\config\blender_full.cmake"
77 ) else if "%1" == "lite" (
78 set BUILD_DIR=%BUILD_DIR%_lite
79 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
80 -C"%BLENDER_DIR%\build_files\cmake\config\blender_lite.cmake"
81 ) else if "%1" == "cycles" (
82 set BUILD_DIR=%BUILD_DIR%_cycles
83 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
84 -C"%BLENDER_DIR%\build_files\cmake\config\cycles_standalone.cmake"
85 ) else if "%1" == "headless" (
86 set BUILD_DIR=%BUILD_DIR%_headless
87 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
88 -C"%BLENDER_DIR%\build_files\cmake\config\blender_headless.cmake"
89 ) else if "%1" == "bpy" (
90 set BUILD_DIR=%BUILD_DIR%_bpy
91 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
92 -C"%BLENDER_DIR%\build_files\cmake\config\bpy_module.cmake"
94 REM Non-Build Commands
95 ) else if "%1" == "update" (
98 git submodule foreach git pull --rebase origin master
100 ) else if "%1" == "clean" (
102 %BUILD_DIR%\Blender.sln ^
104 /property:Configuration=%BUILD_TYPE% ^
106 if %ERRORLEVEL% NEQ 0 (
107 echo Cleaned "%BUILD_DIR%"
111 echo Command "%1" unknown, aborting!
119 if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
120 set WINDOWS_ARCH=Win64
121 ) else if "%PROCESSOR_ARCHITEW6432%" == "AMD64" (
122 set WINDOWS_ARCH=Win64
127 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio 12 2013 %WINDOWS_ARCH%"
128 if NOT EXIST %BUILD_DIR%\nul (
132 REM Only configure on first run
133 if NOT EXIST %BUILD_DIR%\Blender.sln (
140 if %ERRORLEVEL% NEQ 0 (
141 echo "Configuration Failed"
147 %BUILD_DIR%\Blender.sln ^
149 /property:Configuration=%BUILD_TYPE% ^
153 if %ERRORLEVEL% NEQ 0 (
159 %BUILD_DIR%\INSTALL.vcxproj ^
160 /property:Configuration=%BUILD_TYPE% ^
164 echo At any point you can optionally modify your build configuration by editing:
165 echo "%BUILD_DIR%\CMakeCache.txt", then run "make" again to build with the changes applied.
167 echo Blender successfully built, run from: "%BUILD_DIR%\bin\%BUILD_TYPE%"