CMake变量(提供信息的变量)

 

 目录

CMAKE_VERSION

CMAKE_MAJOR_VERSION

CMAKE_MINOR_VERSION

CMAKE_PATCH_VERSION

CMAKE_TWEAK_VERSION

CMAKE_PROJECT_NAME

CMAKE_BINARY_DIR

CMAKE_SOURCE_DIR

CMAKE_CURRENT_BINARY_DIR

CMAKE_CURRENT_SOURCE_DIR

PROJECT_NAME

PROJECT_VERSION

PROJECT_VERSION_MAJOR

PROJECT_VERSION_MINOR

PROJECT_VERSION_PATCH

PROJECT_VERSION_TWEAK

PROJECT_BINARY_DIR

PROJECT_SOURCE_DIR

<PROJECT_NAME>_VERSION

<PROJECT_NAME>_VERSION_MAJOR

<PROJECT_NAME>_VERSION_MINOR

 <PROJECT_NAME>_VERSION_PATCH

<PROJECT_NAME>_VERSION_TWEAK

<PROJECT_NAME>_SOURCE_DIR

<PROJECT_NAME>_BINARY_DIR

First:

CMAKE_VERSION

The CMake version string as three non-negative integer components separated by . and possibly followed by - and other information. The first two components
represent the feature level and the third component represents either a bug-fix level or development date. Release versions and release candidate versions of CMake use the format: <major>.<minor>.<patch>[-rc<n>] where the <patch> component is less than 20000000. Development versions of CMake use the format: <major>.<minor>.<date>[-<id>] where the <date> component is of format CCYYMMDD and <id> may contain arbitrary(任意的) text. This represents development as of a particular date following
the <major>.<minor> feature release.

CMAKE_MAJOR_VERSION

CMAKE_MINOR_VERSION

CMAKE_PATCH_VERSION

CMAKE_TWEAK_VERSION

Individual component values of CMAKE_VERSION 

  CMAKE_TWEAK_VERSION is defined to 0 for compatibility with code written for older CMake versions that may have defined higher values.Because in CMake versions 2.8.2 through 2.8.12, this variable holds the fourth version number component of the CMAKE_VERSION variable.

CMAKE_BINARY_DIR

The path to the top level of the build tree.
This is the full path to the top level of the current CMake build tree. For an in-source build, this would be the same as CMAKE_SOURCE_DIR.

CMAKE_SOURCE_DIR

The path to the top level of the source tree.
This is the full path to the top level of the current CMake source tree. For an in-source build, this would be the same as CMAKE_BINARY_DIR
顶层CMakeLists.txt文件所在路径。

CMAKE_CURRENT_BINARY_DIR

CMAKE_CURRENT_SOURCE_DIR

#add_subdirectory() will create a binary and a source directory in the build tree, and as it is being processed this variableswill be set. 
add_subdirectory(source_dir [binary_dir])
#Add a subdirectory(子路径) to the build.
#The source_dir specifies the directory in which the source CMakeLists.txt and code files are located.If it is a relative path, it will be evaluated with
#respect to the current directory (the typical usage), but it may also be an absolute path.
#The binary_dir specifies the directory in which to place the output files. If it is a relative path it will be evaluated with respect to the current
#output directory, but it may also be an absolute path. If binary_dir is not specified, the value of source_dir, before expanding any relative path, will
#be used.
#子路径下的CMakeLists.txt执行完之后才会继续执行add_subdirectory()下一条语句子。

Second

PROJECT_VERSION

Value given to the VERSION option of the most recent call to the project() command, if any.

PROJECT_VERSION_MAJOR

PROJECT_VERSION_MINOR

PROJECT_VERSION_PATCH

PROJECT_VERSION_TWEAK

First version number component of the PROJECT_VERSION variable as set by the project() command.
Second...
...

PROJECT_BINARY_DIR

Full path to build directory for project.
This is the binary directory of the most recent project() command.

PROJECT_SOURCE_DIR

Top level source directory for the current project.
This is the source directory of the most recent project() command.

Third:

PROJECT_NAME

#The name of the current project.
#This specifies name of the current project from the closest inherited project() command.
project(<PROJECT_NAME> [LANGUAGES] [<language-name>...])

<PROJECT_NAME>_VERSION

Value given to the VERSION option of the most recent call to the project() command with project name <PROJECT-NAME>, if any.

<PROJECT_NAME>_VERSION_MAJOR

<PROJECT_NAME>_VERSION_MINOR

 <PROJECT_NAME>_VERSION_PATCH

<PROJECT_NAME>_VERSION_TWEAK

...

<PROJECT_NAME>_SOURCE_DIR

<PROJECT_NAME>_BINARY_DIR

Top level source directory for the named project.
Top level binary directory for the named project.
A variable is created with the name used in the project() command, and is the source directory and binary directory for the project. This can be useful 
when add_subdirectory() is used to connect several projects.
posted @ 2019-07-14 17:11  心田居士  阅读(488)  评论(0编辑  收藏  举报