CMake usage notes

Source: Internet
Author: User

I recently learned the source code of Mysql and used CMake as the Build tool.

By using CMake to scan system configurations, the config. h file is generated. This header file contains a series of macros prefixed with HAVE.

Config. h. cmake in the source code root directory is a template file that contains all scanning items.

In the Mysql shadow compilation directory (I usually use shadow compilation to keep the purity of the source code directory), we can find config. h, the CMake script will set config. copy h to another file named my_config.h with exactly the same content.

We now take the HAVE_NPTL macro used in Mysql source code as an example to learn the principle of CMake:

We browse the CMake directory of the Mysql directory. This is the Mysql proprietary CMake script. We found the HAVE_NPTL definition in cmake \ OS \ linux. cmake.

In this file, HAVE_NPTL is fixed to 1. We will continue to learn about unfixed settings.

For example, CHECK_SYMBOL_EXISTS (SHM_HUGETLB sys/shm. h HAVE_DECL_SHM_HUGETLB)

The CMake file contains INCLUDE (CheckSymbolExists)

CheckSymbolExists is the common module of CMake and my machine is located under the/usr/share/cmake-2.8/Modules directory.

We will continue to study this document:

After reading the source code, MACRO (CHECK_SYMBOL_EXISTS symbol files variable)

The function of this macro is to find whether the relevant FILES contain the relevant SYMBOL (SYMBOL). If it exists, set VARIABLE to 1, and the MESSAGE macro prints the relevant information on the screen.

In the above column, search for the SHM_HUGETLB symbol in the sys/shm. h file.

View/usr/include/shm. h

Related Article

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.