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