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

Posted liuzhenbo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CMake变量(提供信息的变量)相关的知识,希望对你有一定的参考价值。

 

 

 

 

 

 

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命令的执行目录。

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 variables
#will 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()下一条语句。

CMAKE_PROJECT_NAME

 

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()语句中指定的PROJECT_NAME.

 

PROJECT_VERSION

 

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

 

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.

 

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_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>_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.

 

<PROJECT_NAME>_VERSION_MAJOR

<PROJECT_NAME>_VERSION_MINOR

 <PROJECT_NAME>_VERSION_PATCH

<PROJECT_NAME>_VERSION_TWEAK

 

...

 

以上是关于CMake变量(提供信息的变量)的主要内容,如果未能解决你的问题,请参考以下文章

11-cmake语法-内部变量-系统信息

Cmake知识整理

如何检查 cmake 内部变量?

cmake 常用变量和常用环境变量

cmake set命令

CMake--变量