talklobi.blogg.se

Cmake print variable
Cmake print variable













cmake print variable
  1. #Cmake print variable full version#
  2. #Cmake print variable Patch#

_VERSION_MAJOR – major component of the version string given to project call with the name.

#Cmake print variable full version#

_VERSION – full version string given to the project call with the name. _BINARY_DIR – build directory corresponding to the source directory of the _SOURCE_DIR. _SOURCE_DIR – directory of the project call with the name. There’s yet another set of variables defined, also with each project call: In that case, it’s best to use only the variables relative to the most recent project call, unless you’re absolutely certain you wish to refer to the top-most one. Those decisions start to matter only in larger projects which contain multiple subprojects. In a very simple project, it’s very likely that there will be only a single project command call, in that case, doesn’t really matter which of these variables you decide to use. Some of these may seem somewhat redundant.

cmake print variable

#Cmake print variable Patch#

PROJECT_VERSION_PATCH – patch component of the version string given to the most recent project call. PROJECT_VERSION_MINOR – minor component of the version string given to the most recent project call. PROJECT_VERSION_MAJOR – major component of the version string given to the most recent project call. PROJECT_VERSION – full version string given to the most recent project call. PROJECT_BINARY_DIR – build directory corresponding to the source directory of the most recent project call. PROJECT_SOURCE_DIR – directory of the most recent project call. PROJECT_NAME – name given to the most recent project call. Note that it’s also possible to specify a “_TWEAK” version component, which I’ve omitted here since it’s not semver compliant.Īdditionally, the following variables become available after every project command call: The very first project command call defines the following set of variables:ĬMAKE_PROJECT_NAME – name specified in the very first project call.ĬMAKE_PROJECT_VERSION – full version string given in the very first project call.ĬMAKE_PROJECT_VERSION_MAJOR – major component of the version string given to the very first project call.ĬMAKE_PROJECT_VERSION_MINOR – minor component of the version string given to the very first project call.ĬMAKE_PROJECT_VERSION_PATCH – patch component of the version string given to the very first project call. Both can be useful, depending on the application. These variables either refer to the most recent project command call, or are constant across the entire build process. In addition to the globally available variables another set of variables becomes available after the project command is called. Alternatively it may be the binary directory explicitly specified to the add_subdirectory call. The following variables are always available:ĬMAKE_SOURCE_DIR – points to the root project source directory – this is the directory the top-level CMakeLists.txt is located at.ĬMAKE_BINARY_DIR – points to the root of the build directory – this is the directory cmake was originally executed from, or the directory passed in with the -B flag.ĬMAKE_CURRENT_SOURCE_DIR – points to the directory of the CMakeLists.txt currently being processed, or in other words the directory of the most recent add_subdirectory call.ĬMAKE_CURRENT_BINARY_DIR – points to the build directory corresponding to the CMAKE_CURRENT_SOURCE_DIR – of the same name, mirroring the source tree, is created within the build directory for each add_subdirectory call. Here I’ll be focusing strictly on variables providing a directory-context – for example the variables one might use when referencing the top of the project directory tree, current directory, etc. All variables with the CMAKE_ prefix are reserved by CMake itself. Most, but not all of them begin with the CMAKE_ prefix. The total number of global variables exposed by CMake is rather large. In this post, I discuss what variables are available and provide general advice on which one might be the best choice depending on a use-case. Some of these variables are global and constant across the entire build process, but some change depending on the current scope (context). CMake exposes a large set of built-in variables that provide the user with information about the project’s structure.















Cmake print variable