eATM

visual studio 2022/2019批量生成cmake项目

#BuildAll.bat 
#这里面的路径,是各个配置中的生成目录,是由CMake生成好的配置

@echo off
chcp 65001 > NULL

echo build lib_x86_Debug
CMake.exe --build "E:\easy_cpp\easylib\out\build\lib_x86_Debug" %1 --config Debug
if %errorlevel% neq 0 (
    exit /b %errorlevel%
)

echo build lib_x64_Debug
CMake.exe --build "E:\easy_cpp\easylib\out\build\lib_x64_Debug" %1 --config Debug
if %errorlevel% neq 0 (
    exit /b %errorlevel%
)

echo build lib_x86_Release
CMake.exe --build "E:\easy_cpp\easylib\out\build\lib_x86_Release" %1 --config Release
if %errorlevel% neq 0 (
    exit /b %errorlevel%
)

echo build lib_x64_Release
CMake.exe --build "E:\easy_cpp\easylib\out\build\lib_x64_Release" %1 --config Release
if %errorlevel% neq 0 (
    exit /b %errorlevel%
)

echo.
echo ******************************************************
echo All compiled successfully
echo ******************************************************

 

另外创建个tasks.vs.json文件到根目录

#tasks.vs.json

{
    "version": "0.2.1",
    "tasks": [
        {
            "taskLabel": "★★★★[编译全部项目]",
            "appliesTo": "*",
            "type": "launch",
            "command": "BuildAll.bat",
            "args": []
        },
        {
            "taskLabel": "★★★★[重新编译全部项目]",
            "appliesTo": "*",
            "type": "launch",
            "command": "BuildAll.bat",
            "args": [
                "--clean-first"
            ]
        }
    ]
}

 

解决方案文件夹视图中,右键即可

编译时如果有错误,中文可能会显示乱码

是批处理中设置了65001编码造成的,不设置这个编码就会出现编译时会有无数个”注意:包含文件 xxxxx”的警告

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注