Cleanup: use override/final for derived classes.
[blender.git] / build_files / windows / configure_ninja.cmd
1 ninja --version 1>NUL 2>&1
2 if %ERRORLEVEL% NEQ 0 (
3                 echo "Ninja not detected in the path"
4                 exit /b 1
5         )
6
7 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Ninja" %TESTS_CMAKE_ARGS% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
8
9 if "%BUILD_WITH_SCCACHE%"=="1" (
10         set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DWITH_WINDOWS_SCCACHE=On
11         if NOT "%verbose%" == "" (
12                 echo Enabling sccache
13         )
14 )
15
16 if "%WITH_CLANG%" == "1" (
17 set LLVM_DIR=
18         for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LLVM\LLVM" /ve 2^>nul`) DO set LLVM_DIR=%%C
19         if DEFINED LLVM_DIR (
20                 if NOT "%verbose%" == "" (
21                         echo LLVM Detected at "%LLVM_DIR%"
22                 )
23         goto DetectionComplete
24         )
25
26         REM Check 32 bits
27         for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\LLVM\LLVM" /ve 2^>nul`) DO set LLVM_DIR=%%C
28         if DEFINED LLVM_DIR (
29                 if NOT "%verbose%" == "" (
30                         echo LLVM Detected at "%LLVM_DIR%"
31                 )
32                 goto DetectionComplete
33         )
34         echo LLVM not found 
35         exit /b 1
36         
37 :DetectionComplete      
38         set CC=%LLVM_DIR%\bin\clang-cl
39         set CXX=%LLVM_DIR%\bin\clang-cl
40         if "%BUILD_VS_YEAR%" == "2019" (
41                 rem build and tested against 2019 16.2
42                 set CFLAGS=-m64 -fmsc-version=1922
43                 set CXXFLAGS=-m64 -fmsc-version=1922
44         ) else (
45                 rem build and tested against 2017 15.7
46                 set CFLAGS=-m64 -fmsc-version=1914
47                 set CXXFLAGS=-m64 -fmsc-version=1914
48         )
49 )
50
51 if "%WITH_ASAN%"=="1" (
52         set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DWITH_COMPILER_ASAN=On
53 )
54
55 if NOT "%verbose%" == "" (
56         echo BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% 
57 )
58
59 if NOT EXIST %BUILD_DIR%\nul (
60         mkdir %BUILD_DIR%
61 )
62
63 if "%MUST_CLEAN%"=="1" (
64         echo Cleaning %BUILD_DIR%
65         cd %BUILD_DIR%
66         %CMAKE% cmake --build . --config Clean
67 )
68
69 if NOT EXIST %BUILD_DIR%\build.ninja set MUST_CONFIGURE=1
70 if "%NOBUILD%"=="1" set MUST_CONFIGURE=1
71
72 if "%MUST_CONFIGURE%"=="1" (
73         cmake ^
74                 %BUILD_CMAKE_ARGS% ^
75                 -H%BLENDER_DIR% ^
76                 -B%BUILD_DIR% 
77
78         if %ERRORLEVEL% NEQ 0 (
79                 echo "Configuration Failed"
80                 exit /b 1
81         )
82 )
83
84 echo echo off > %BUILD_DIR%\rebuild.cmd
85 echo if "%%VSCMD_VER%%" == "" ^( >> %BUILD_DIR%\rebuild.cmd
86 echo   call "%VCVARS%" %BUILD_ARCH% >> %BUILD_DIR%\rebuild.cmd
87 echo ^) >> %BUILD_DIR%\rebuild.cmd
88 echo echo %%TIME%% ^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd
89 echo ninja install %%* >> %BUILD_DIR%\rebuild.cmd
90 echo echo %%TIME%% ^>^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd