Qt6.3 + Clion +MSVC2019环境配置详解
作者:he_yang_
本文主要介绍了Qt6.3 + Clion +MSVC2019环境配置详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
1. VS2022中下载2019的编译环境
2. Clion中配置工具链
注意选amd64
3. CMake选择MSVC工具链
4. 编写CMakeLists.txt
cmake_minimum_required(VERSION 3.5) project(Pentagram VERSION 0.1 LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(QT_PATH "$ENV{QT6_DIR}") set(CMAKE_PREFIX_PATH ${QT_PATH}) #这里需要填入自己安装的路径 find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools) aux_source_directory(. DIRS_SRCS) # 当前文件夹加入cmake aux_source_directory(ui DIRS_SRCS) # 当前文件夹加入cmake set(SOURCE_FILES ${DIRS_SRCS} ) set(PROJECT_SOURCES ${SOURCE_FILES} ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(Pentagram MANUAL_FINALIZATION ${PROJECT_SOURCES} ) qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR}) else() if(ANDROID) add_library(Pentagram SHARED ${PROJECT_SOURCES} ) # Define properties for Android with Qt 5 after find_package() calls as: # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") else() add_executable(Pentagram ${PROJECT_SOURCES} ) endif() qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) endif() target_link_libraries(Pentagram PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) set_target_properties(Pentagram PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE # WIN32_EXECUTABLE TRUE # 去掉注释则保留控制台, 可以看到输出 ) if(QT_VERSION_MAJOR EQUAL 6) qt_finalize_executable(Pentagram) endif()
5. 配置环境变量
6 完事
到此这篇关于Qt6.3 + Clion +MSVC2019环境配置详解的文章就介绍到这了,更多相关Qt6.3 MSVC2019环境配置内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!