Add Asan support for clang on windows.
[blender.git] / build_files / windows / configure_ninja.cmd
1 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Ninja" %TESTS_CMAKE_ARGS% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
2
3 if "%WITH_CLANG%" == "1" (
4 set LLVM_DIR=
5         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
6         if DEFINED LLVM_DIR (
7                 if NOT "%verbose%" == "" (
8                         echo LLVM Detected at "%LLVM_DIR%"
9                 )
10         goto DetectionComplete
11         )
12
13         REM Check 32 bits
14         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
15         if DEFINED LLVM_DIR (
16                 if NOT "%verbose%" == "" (
17                         echo LLVM Detected at "%LLVM_DIR%"
18                 )
19                 goto DetectionComplete
20         )
21         echo LLVM not found 
22         exit /b 1
23         
24 :DetectionComplete      
25         set CC=%LLVM_DIR%\bin\clang-cl
26         set CXX=%LLVM_DIR%\bin\clang-cl
27         rem build and tested against 2017 15.7
28         set CFLAGS=-m64 -fmsc-version=1914
29         set CXXFLAGS=-m64 -fmsc-version=1914
30         if "%WITH_ASAN%"=="1" (
31                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DWITH_COMPILER_ASAN=On
32         )       
33 )
34
35 if "%WITH_ASAN%"=="1" (
36         if "%WITH_CLANG%" == "" (
37                 echo ASAN is only supported with clang.
38                 exit /b 1 
39         )
40 )
41
42 if NOT "%verbose%" == "" (
43         echo BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% 
44 )
45
46 if NOT EXIST %BUILD_DIR%\nul (
47         mkdir %BUILD_DIR%
48 )
49
50 if "%MUST_CLEAN%"=="1" (
51         echo Cleaning %BUILD_DIR%
52         cd %BUILD_DIR%
53         %CMAKE% cmake --build . --config Clean
54 )
55
56 if NOT EXIST %BUILD_DIR%\Blender.sln set MUST_CONFIGURE=1
57 if "%NOBUILD%"=="1" set MUST_CONFIGURE=1
58
59 if "%MUST_CONFIGURE%"=="1" (
60         cmake ^
61                 %BUILD_CMAKE_ARGS% ^
62                 -H%BLENDER_DIR% ^
63                 -B%BUILD_DIR% 
64
65         if %ERRORLEVEL% NEQ 0 (
66                 echo "Configuration Failed"
67                 exit /b 1
68         )
69 )
70
71 echo call "%VCVARS%" %BUILD_ARCH% > %BUILD_DIR%\rebuild.cmd
72 echo echo %%TIME%% ^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd
73 echo ninja install >> %BUILD_DIR%\rebuild.cmd 
74 echo echo %%TIME%% ^>^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd