!57 自动构建windows平台msvc版本的bat脚本

Merge pull request !57 from ansicheng/cmake-dev
This commit is contained in:
爬山虎 2023-03-09 09:36:11 +00:00 committed by Gitee
commit 664f4b0923
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 111 additions and 1 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22) cmake_minimum_required(VERSION 3.20)
project(Notepad-- VERSION 1.23.2) project(Notepad-- VERSION 1.23.2)

37
win-mingw-make-msbuild.mk Normal file
View File

@ -0,0 +1,37 @@
# 基于 powershell 环境编写
# windows 下mingw32-make.exe cmake.exe msbuild.exe cl.exe工具链编译
# 使用方式 mingw32-make -f win-mingw-make-msbuild.mk
# 填入cmake程序完整路径
CMAKE_TOOL:=D:\Soft\mingw64\bin\cmake.exe
# 填入cpack程序完整路径
CPACK_TOOL:=D:\Soft\mingw64\bin\cpack.exe
# 填入MSVC工具链路径
# 填入msbuild程序完整路径
MSBUILD_TOOL:=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe
# 填入cl程序完整路径
CL_COMPILER:=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe
# 填入Qt的msvc相关工具安装路径
# 填入MSVC Qt库查找路径
Qt_MSVC_PREFIX_PATH:=d:\Soft\Qt\5.15.2\msvc2019_64
NUM_LOGICAL_PROCESSOR=$(shell powershell (Get-CimInstance -ClassName Win32_Processor).NumberOfLogicalProcessors)
ifneq ($(shell powershell Test-Path build\bin\plugin), True)
MKDIR:=mkdir -p build\bin\plugin
endif
all:msvc
msvc:
${CMAKE_TOOL} -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MSVC_PREFIX_PATH} .
${CMAKE_TOOL} --build ./build --config=Release -j${NUM_LOGICAL_PROCESSOR}
$(shell powershell New-Item -ErrorAction SilentlyContinue -Type Directory build\bin\plugin)
$(shell powershell cp -Force build\Release\NotePad--.exe build\bin\)
cd build/bin && ${Qt_MSVC_PREFIX_PATH}\bin\windeployqt.exe --qmldir=${Qt_MSVC_PREFIX_PATH}\bin\qml NotePad--.exe
$(shell powershell cp -r -Force build\src\*\*\Release\*.dll build\bin\plugin)
$(shell powershell cp -r -Force build\src\*\Release\*.lib build\bin\plugin)
cd build && ${CPACK_TOOL} --config CPackConfig.cmake

73
windows.bat Normal file
View File

@ -0,0 +1,73 @@
@echo off
set build_dir=build
set source_dir=.
set generator=-G Ninja
set build_type_debug=Debug
set build_type_release=Relase
set build_type=%build_type_debug%
set universal=ON
set qt=ON
set qt5=ON
set qt6=OFF
echo finding vcvars64.bat...
set vcvars=
for %%i in (C: D: E: F: G: H:) do (
if exist %%i (
pushd %%i\
for /r %%j in (*vcvars64.bat) do (
set vcvars=%%j
popd
goto :find_vcvars
)
popd
)
)
:find_vcvars
if not "%vcvars%"=="" (
call "%vcvars%"
echo config MSVC environment...
)else (
echo error: could not find vcvars64.bat MSVC ENV config file.
goto :out
)
echo finding qt msvc path...
set qt_msvc=
for %%i in (D: D: E: F: G: H:) do (
if exist %%i (
pushd %%i\
for /d /r %%j in (*msvc20*) do (
echo %%j
if exist %%j\bin (
if exist %%j\bin\windeployqt.exe (
if exist %%j\bin\Qt5Core.dll (
set qt_msvc=%%j
popd
goto :find_qt_msvc
)
)
)
)
popd
)
)
:find_qt_msvc
if not "%qt_msvc%"=="" (
echo config qt msvc path...
) else (
echo error: could not find qt msvc path.
goto :out
)
cmake -B%build_dir% CMAKE_BUILD_TYPE=%build_type% %generator% -DUSE_WINDOWS_UNIVERSAL=%universal% -DWINDOWS_DEPLOY_QT=%qt% -DWINDOWS_DEPLOY_QT5=%qt5% -DWINDOWS_DEPLOY_QT6=%qt6% -DCMAKE_PREFIX_PATH=%qt_msvc% %source_dir%
cmake --build %build_dir% --
xcopy %build_dir%\windows-deployqt\Notepad--.app\bin\ %build_dir%\bin\ /e
:out
pause