月度归档:2023年01月

CMAKE增加Debug的后缀

set_target_properties(ptyqt-agent PROPERTIES DEBUG_POSTFIX "d")
set_target_properties(ptyqt PROPERTIES DEBUG_POSTFIX "d")
而 set(CMAKE_DEBUG_POSTFIX "d") 仅对add_library这类会增加后缀,而add_executable这种是不行的。

如何设置修改Qt配置,使其支持指定的WindowSDK。

在开发过程中需要实现ConPTY的支持,故不得不指定WindowsSDK进行编译。

ConPTY的支持是从Window10的1809系统版本开始,据网友实测,从Windows 10 SDK version 1903 (10.0.18362.1)版本才支持ConPTY,其下载地址:https://software-static.download.prss.microsoft.com/pr/download/18362.1.190318-1202.19h1_release_WindowsSDK.iso
在小于1903的SDK版本中编译ConPTY代码,是可以编译通过的,但实际上是无法启用ConPTY的。

以下方法不是最佳方法,且也只能解决pro工程问题,而cmake类的编译,貌似无法解决。

QtCreator是不支持设置WindowSDK版本的,那该如何修改使其支持呢?以VS2015为例如下所示:

我们打开vcvarsall.bat的批处理文件,因为Qt已经初始化了目标平台的指令如x86,故我们修改的位置如下:

if "%1" == "" goto x86

rem 屏蔽goto指令
rem if "%2" == "" goto check_platform  

rem 增加以下call指令
if "%2" == "" (
    echo "In order to specify the SDK version for compilation, the following instructions will be rewritten."
    echo "If an error is reported, please check whether your SDK version number is correct."
    echo "The new command as bellow:"
    echo "%~0 %1 10.0.18362.0"
    call "%~0" %1 10.0.18362.0
    goto :eof
)
setlocal
set _Argument2=%2
if not "%2"=="store" if not "%2"=="8.1" if not "%_Argument2:~0,3%"=="10."  goto usage
endlocal

若命令行编译呢?则可如下所示:

@echo off
if "%QT_TOOLCHAIN%" == "" (    
    echo "failed to find the environment variable:QT_TOOLCHAIN"
    echo "add varianble to environment like: QT_TOOCHAIN=C:\Qt\Qt5.12.12\5.12.12\msvc2017"   
    pause 
    exit
)

echo %QT_TOOLCHAIN%|find "msvc2015" >nul
if %errorlevel% neq 0 (
    call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 10.0.18362.0
) else (
    call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 10.0.18362.0
)
call "%QT_TOOLCHAIN%\bin\qtenv2.bat"

当前最新版本:Windows 10 SDK version 2104 (10.0.20348.0)也仍是支持WINDOW 7