CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0) project(hello VERSION 0.1.0) include(
CTest) enable_testing() #qt项目moc相关的 set(CMAKE_INCLUDE_CURRENT_DIR ON) set(
CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(
CMAKE_CXX_STANDARD17) set(CMAKE_CXX_STANDARD_REQUIRED ON) # 查找qt相关包 find_package
(Qt5 COMPONENTS Widgets Core Gui REQUIRED) # WIN32 增加了这个标志则不会带控制台 add_executable
(hello WIN32 main.cpp widget.ui) set(CPACK_PROJECT_NAME ${PROJECT_NAME}) set(
CPACK_PROJECT_VERSION ${PROJECT_VERSION}) include(CPack) # 连接相关包
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Core Qt5::Gui)
xxx.qrc 资源文件格式参考
<RCC> <qresource prefix="/"> <file>01.jpg</file> </qresource> </RCC>