CMake构建Qt5的VS2015 (Hello Qt5)

时间:2022-01-16 13:50:37

Qt5的编译

https://www.cnblogs.com/dilex/p/10611913.html

 

CMakeLists.txt 源码

cmake_minimum_required(VERSION 2.8.11)
project(HelloQt5)
# Find the QtWidgets library
find_package(Qt5Widgets)
# Tell CMake to create the HelloQt5 executable
add_executable(HelloQt5 WIN32 main.cpp)
# Use the Widgets module from Qt 5.
target_link_libraries(HelloQt5 Qt5::Widgets)

 

main.cpp 源码

#include <QApplication>
#include <QLabel>

int main(int argc, char* argv[])
{
	QApplication app(argc, argv);
	QLabel *label = new QLabel("Hello Qt5!");
	label->show();
	return app.exec();
}