43 lines
1.4 KiB
Batchfile
Vendored
43 lines
1.4 KiB
Batchfile
Vendored
@echo off
|
||
|
||
@rem 查找cmake安装位置
|
||
vswhere.exe -latest -products * -requires Microsoft.VisualStudio.Component.VC.CMake.Project -find "**/CMake/bin/cmake.exe" >temp.txt
|
||
set/p PATH_CMAKE=<temp.txt
|
||
del temp.txt
|
||
echo cmake位置:%PATH_CMAKE%
|
||
|
||
@rem 查找ninja安装位置
|
||
vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.CMake.Project -find "**/CMake/Ninja/ninja.exe" >temp.txt
|
||
set/p PATH_NINJA=<temp.txt
|
||
del temp.txt
|
||
echo Ninja位置:%PATH_NINJA%
|
||
|
||
@rem 查找vs安装位置
|
||
vswhere.exe -latest -prerelease -property installationPath >temp.txt
|
||
set/p PATH_VS_ROOT=<temp.txt
|
||
del temp.txt
|
||
|
||
set PATH_VCVARS=%PATH_VS_ROOT%\VC\Auxiliary\Build\vcvarsall.bat
|
||
echo vs编译脚本位置:%PATH_VCVARS%
|
||
|
||
:: 1. 获取VS安装路径
|
||
for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
|
||
set "VS_PATH=%%i"
|
||
)
|
||
|
||
:: 2. 获取MSVC版本号
|
||
for /f "usebackq tokens=*" %%v in (`dir /b "%VS_PATH%\VC\Tools\MSVC"`) do (
|
||
set "MSVC_VER=%%v"
|
||
)
|
||
|
||
:: 3. 拼接 cl.exe 路径(x64)
|
||
set "CL_PATH=%VS_PATH%\VC\Tools\MSVC\%MSVC_VER%\bin\Hostx64\x64\cl.exe"
|
||
|
||
|
||
pause
|
||
|
||
@REM 解析工程(cmake)
|
||
%PATH_CMAKE% -G "Ninja" -DCMAKE_C_COMPILER:STRING="cl.exe" -DCMAKE_CXX_COMPILER:STRING=%CL_PATH% -DODE_WITH_DEMOS:BOOL="FALSE" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="D:/dl/out/install/x64-debug" -DCMAKE_MAKE_PROGRAM=%PATH_NINJA% "D:\dl"
|
||
|
||
|
||
pause |