Skip to content

Commit 1ff4d49

Browse files
Merge pull request #5458 from hannes-steffenhagen-diffblue/set-cmake-project-version
Set CMake project version based on config.inc
2 parents 6301c3f + f8cdbb0 commit 1ff4d49

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
cmake_minimum_required(VERSION 3.2)
22

3-
project(CBMC)
3+
4+
# Grab the current CBMC version from config.inc
5+
# We do this so we have a matching cbmc version between the Makefile build and
6+
# the CMake build. This version info is useful for things like generating
7+
# packages (which usually need to contain version info in their metadata and
8+
# filenames)
9+
file(
10+
STRINGS src/config.inc CBMC_VERSION
11+
REGEX "CBMC_VERSION = (.*)")
12+
string(REGEX REPLACE "CBMC_VERSION = (.*)" "\\1" CBMC_VERSION ${CBMC_VERSION})
13+
14+
project(CBMC VERSION ${CBMC_VERSION})
15+
16+
# when config.inc changes we’ll need to reconfigure to check if the version changed
17+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/config.inc")
418

519
find_program(CCACHE_PROGRAM ccache)
620
if(CCACHE_PROGRAM)

0 commit comments

Comments
 (0)