Many people use the QT creator to develop, creator is really very convenient, but debugging up, there is no vs fast.
CMake is used for the start of larger projects, and the VS combination is powerful, plus a more convenient debugging advantage than creator, or a good choice.
As a result of nearly one or two years of contact with several projects, are used VS2010 + qt4.8 + cmake frame, so summed up a number of methods, but also felt that its large projects, the great role played. It can put the project source code and compile the content module, all separate, make the structure is very clear.
Here is a talk about the simplest Qt4.8 + vs2010 + cmake environment. One of the simplest examples:
1. Install CMake. The CMake installation package can be found on the Internet for downloading and installing.
Installation of 2.vs 2010.
3.qt4.8 source code compilation. Finally, you need to add environment variables.
4. Put the simplest five files under one directory, such as the example I used CMakeLists.txt cmakeqtvs.cpp cmakeqtvs.h cmakeqtvs.ui main.cpp
CMakeLists.txt this is necessary, and the name must be the same.
The content of my face here is:
Cmake_minimum_required (VERSION 2.6 fatal_error)
Project (Cmake_qt_vs_test)
Find_package (Qt4 REQUIRED)
Set (in ${project_source_dir})
Include_directories (${in})
Set (project_sources main.cpp cmakeqtvs.cpp)
Set (Project_headers cmakeqtvs.h)
Set (Project_forms cmakeqtvs.ui)
Qt4_wrap_cpp (Project_headers_moc ${project_headers})
QT4_WRAP_UI (Project_forms_headers ${project_forms})
INCLUDE (${qt_use_file})
Add_definitions (${qt_definitions})
Add_executable (Cmake_qt_vs_test ${project_sources}
${project_forms_headers}
${PROJECT_HEADERS_MOC})
Target_link_libraries (Cmake_qt_vs_test ${qt_libraries})
The above script is configured for an environment, including the CMake minimum version, the addition of the QT Library, the SOURC, header, and forms file storage.
Cmakeqtvs.cpp cmakeqtvs.h Cmakeqtvs.ui main.cpp as a test, these files can be manually written by themselves, or they can be generated directly through the creator,
and copy it over. Worth a value is that the original cmakeqtvs.cpp in the header file, is #include "ui_cmakeqtvs.h" now to change to you now CMake after the selected path, I am here #include "build/ui_cmakeqtvs.h"
My directory structure here is:
The build is generated later, and builds are below the Cmakeqtvs directory so that #include "Build/ui_cmakeqtvs.h" contains the header file before it can be found. The build directory is not required before the CMake is opened.
5. Open CMake
The top two select input boxes, the first is to select the location of the source code, the second option is the location of the project build. I put the build here, under the source directory, and then built a build directory, but also for the header file to find the automatically generated after the Ui_cmakeqtvs.h file.
After matching the path, then click Configure and Generate separately, as long as there is no red false hint even if the environment is set up correctly.
Open the automatically generated build file below, Cmake_qt_vs_test.sln, after the birth, there will be the following files:
Then, if there is no problem with compilation debugging, then a simple cmake + vs2010 + qt4.8 compilation environment is built up.