From 5414380422cb6042c4753712de7a69f5f80248d5 Mon Sep 17 00:00:00 2001 From: zinface Date: Wed, 1 Mar 2023 02:53:30 +0800 Subject: [PATCH] =?UTF-8?q?qt5/6:=20=E5=A2=9E=E5=8A=A0=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=80=A7=E6=9E=84=E5=BB=BA=E6=A3=80=E6=9F=A5=E6=96=B9=E6=A1=88?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=96=87=E4=BB=B6=E4=B8=AD=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=20true=20=E5=B0=86=E8=AE=A4=E4=B8=BA=E5=8F=AF?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 10 ++++++++++ cmake/platforms/utils.cmake | 14 ++++++++++++++ cmake/qt5_qt6_compatible_check | 1 + 3 files changed, 25 insertions(+) create mode 100644 cmake/qt5_qt6_compatible_check diff --git a/CMakeLists.txt b/CMakeLists.txt index d51a8c4..f31a8ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,3 +110,13 @@ endif() # ----------------- Notepad-- 其它主线构建相关 ----------------- # +if(USE_QT6) + # Qt5/Qt6 兼容性构建检查文件检查 + include(cmake/platforms/utils.cmake) + qt5_qt6_compatible_check(cmake/qt5_qt6_compatible_check QT56_PASS) + if(NOT QT56_PASS) + message(SEND_ERROR "[${QT56_PASS}] Qt5/Qt6 兼容性检查文件当前未能检查通过,不建议构建 Qt6。") + else() + message(NOTICE "[${QT56_PASS}] Qt5/Qt6 兼容性检查文件当前检查通过。") + endif(NOT QT56_PASS) +endif(USE_QT6) diff --git a/cmake/platforms/utils.cmake b/cmake/platforms/utils.cmake index 74fc596..de5eea8 100644 --- a/cmake/platforms/utils.cmake +++ b/cmake/platforms/utils.cmake @@ -38,3 +38,17 @@ endfunction(get_current_platform_lib_name _VAR _IS_SHREAD _LIB) # 在 MacOS 中 # 用于编译的静态库与动态库后缀分别是:.a 与 .dylib # 文件名称由 lib 开头 + +# qt5_qt6_compatible_check + # Qt5/6 兼容性构建检查方案,如果文件中存在 true 将认为可兼容构建 + # _CHECK_FILE Qt5/Qt6 兼容性检查文件 + # _VAR 检查结果 +function(qt5_qt6_compatible_check _CHECK_FILE _VAR) + set(${_VAR} true PARENT_SCOPE) + file(READ ${_CHECK_FILE} file_content) + string(FIND ${file_content} "true" _index) + if(_index LESS 0) + # -1: It is not checked and passed + set(${_VAR} false PARENT_SCOPE) + endif(_index LESS 0) +endfunction(qt5_qt6_compatible_check _CHECK_FILE _VAR) diff --git a/cmake/qt5_qt6_compatible_check b/cmake/qt5_qt6_compatible_check new file mode 100644 index 0000000..f32a580 --- /dev/null +++ b/cmake/qt5_qt6_compatible_check @@ -0,0 +1 @@ +true \ No newline at end of file