Respect the author, support original, if need to reprint, please enclose the original address:
http://blog.csdn.net/libaineu2004/article/details/78448392
First, preliminary preparation
1, install Linux system, such as CentOS 7, with desktop, GNOME installation
2. Installation Qt-opensource-linux-x64-5.9.1.run
3, installation CMake, reference Tutorial: CentOS 7 Installation CMake 2.8.12.2
Second, the construction of new and C + + project, select "Independent of QT Library" project
Bulid System Please select CMake
When the new project is completed, the CMakeLists.txt file is generated under the path. The next time you need to open the project, the Qtcreator menu opens the File/project, select the CMakeLists.txt file.
Third, how to achieve one step debugging
Method 1 (Recommended): The default construction method of the project is defaults, which means release. You need to adjust to debug to achieve Single-step breakpoint debugging.
When you are done with debug, click "Run CMake" on the menu->build.
Method 2 (not recommended): Due to the cmake default, the Default/release version is generated. We can manually edit the CMakeLists.txt file and add it at the end of the file:
Set (Cmake_build_type Debug), build again.
Iv. How to add c++/c source and header files. How to add a Third-party dependent library and header file.
The only way is to manually modify the CMakeLists.txt file, see
CMake Use example and collation summary
CMake ways to handle multiple-source file directories Please pay attention to the method of adding multiple files Aux_source_directory
CMakeLists.txt of multiple directory engineering (automatically add files under multiple directories) Please pay attention to the method of adding multiple files Aux_source_directory
Example 1:
Set (cmake_cxx_flags "${cmake_cxx_flags}-std=c++0x-g-wall-o0-wno-unused-variable-pthread")
link_directories (
${project_source_dir}/lib
/usr/lib64/mysql/
)
find_library (Mysql_lib libmysqlclient.so/usr/ lib64/mysql/)
IF (not mysql_lib) message
(Fatal_error ' mysqlclient not found ')
ENDIF (not mysql_lib)
Set (Net_srcs
base/timestamp.cpp
base/countdownlatch.cpp
)
Example 2:
Set (Src_list main.c hello.c)
Add_executable (Hello ${src_list})
It's OK to write set this way, but if you have a lot of source files, adding all the names of the source files will be a chore. A more convenient approach is to use the Aux_source_directory command, which looks for all the source files in the specified directory and then saves the results in the specified variable name. The syntax is as follows: Aux_source_directory (<dir> <variable>)
Aux_source_directory (. DIRSRCS)
Add_executable (Hello ${dirsrcs})
Learn CMake Please refer to the article "CMake Practice" to guide users to quickly use CMake, if you need more detailed content, please read the "CMake Practice" this article. Download path: http://sewm.pku.edu.cn/src/paradise/reference/CMake%20Practice.pdf
V. How to implement remote debugging
Visit the Sister chapter "using QT Creator as the Linux IDE instead of vim: Implementing remote Deployment and debugging of two Linux computers (one computer has a desktop system, one computer without a desktop system)," The Web site is: http://blog.csdn.net/ libaineu2004/article/details/62423830
Note: CMake the target path of the remote build, the default is/root/xxx. You can manually modify the CMakeLists.txt file to change the output path, SET (executable_output_path "* * *"). So the path of both the developer and the target machine will have a build result. My test result is, looks like the path inside has the home directory, the target machine is not good. For example, set (Executable_output_path "/home/12/"), the resulting file developer is in, but the target is not, but the folder is generated/12 in the root directory. Another example is the "/home/firecat/test" target machine is not in, but the root directory to generate the "test" folder.
Cmake_minimum_required (VERSION 2.8)
Project (Untitled)
add_executable (${project_name} "main.cpp" "Test.cpp" ")
# #SET (executable_output_path"/home/firecat/test/")
SET (executable_output_path"/hellotest/12/34 ")