1CMAKE_PROJECT_VERSION
2---------------------
3
4.. versionadded:: 3.12
5
6The version of the top level project.
7
8This variable holds the version of the project as specified in the top
9level CMakeLists.txt file by a :command:`project` command.  In the event that
10the top level CMakeLists.txt contains multiple :command:`project` calls,
11the most recently called one from that top level CMakeLists.txt will determine
12the value that ``CMAKE_PROJECT_VERSION`` contains.  For example, consider
13the following top level CMakeLists.txt:
14
15.. code-block:: cmake
16
17  cmake_minimum_required(VERSION 3.0)
18  project(First VERSION 1.2.3)
19  project(Second VERSION 3.4.5)
20  add_subdirectory(sub)
21  project(Third VERSION 6.7.8)
22
23And ``sub/CMakeLists.txt`` with the following contents:
24
25.. code-block:: cmake
26
27  project(SubProj VERSION 1)
28  message("CMAKE_PROJECT_VERSION = ${CMAKE_PROJECT_VERSION}")
29
30The most recently seen :command:`project` command from the top level
31CMakeLists.txt would be ``project(Second ...)``, so this will print::
32
33  CMAKE_PROJECT_VERSION = 3.4.5
34
35To obtain the version from the most recent call to :command:`project` in
36the current directory scope or above, see the :variable:`PROJECT_VERSION`
37variable.
38