CMake Instance Demo

Source: Internet
Author: User

Execution CMake can generate makefile files and some intermediate files, CMake has both internal and external construction operations, the proposed external build, keep the code clean, the project directory structure is clear.

CMake. Represents building the system based on the rules established in the file CMakeLists.txt in the current directory and generating makefile files in the current directory. "Within Build"

CMake.. Represents building the system and generating makefile files in the current directory based on the rules established in the file CMakeLists.txt in the previous level of the directory.

cmake [parameters] [specify directory to compile or directories to hold makefile files] [specify the directory where CMakeLists.txt files are located] "is an external build"

An appetizer.

The file structure in the Hello directory:?

./cmakelists.txt
1 2 3 4 ├──cmakelists.txt├──hello.c├──hello.h└──main.c

The C code is shown in the following section.

Simplest cmake configuration file:?

./cmakelists.txt
1 2 3 Project (Hello) set (src_list main.c hello.c) add_executable (Hello ${src_list})

If you want to compile into the debug version of GDB that you can debug, add the following in the configuration file:?

1 Set (Cmake_build_type Debug)

If you want to compile to a version that is available gprof analysis, add the following in the configuration file:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.