├── cmakelists.txt
└── main.cpp
源文件
main.c
#include
#include
int main(int argc, char *argv[])
{
printf("qt5 cmake:hello\r\n");
return 0;
}
cmakelists.txt
cmake_minimum_required(version 3.5)
project(test_qt5)
set(cmake_cxx_standard 14)
find_package(qt5 components core widgets required)
add_executable(test_qt5 main.cpp)
target_link_libraries(test_qt5 private qt5::core qt5::widgets)
)
第四行使用find_package寻找qt5的库。
编译
$ mkdir build
$ cd build/
$ cmake ..
$ make verbose=1 (打印详细的编译信息,可以看到连接的qt5的so,则配置成功)
./test_qt5
qt5 cmake:hello