Skip to content

Commit c724249

Browse files
Set CMake project version based on config.inc
Currently we set the CBMC version in config.inc. It would be useful to have this information in our CMakeLists.txt as well (especially for e.g. CPack packaging), and to avoid duplication it would be better to have it in just one place. It’s somewhat easier to parse config.inc from CMake than doing it the other way round (and we already do it in src/util/CMakeLists.txt anyway), we do it here.
1 parent 8a99f23 commit c724249

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

CMakeLists.txt

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

3-
project(CBMC)
3+
4+
# Grab the current CBMC version from config.inc
5+
file(
6+
STRINGS src/config.inc CBMC_VERSION
7+
REGEX "CBMC_VERSION = (.*)")
8+
string(REGEX REPLACE "CBMC_VERSION = (.*)" "\\1" CBMC_VERSION ${CBMC_VERSION})
9+
10+
project(CBMC VERSION ${CBMC_VERSION})
11+
12+
# when config.inc changes we’ll need to reconfigure to check if the version changed
13+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/config.inc")
414

515
find_program(CCACHE_PROGRAM ccache)
616
if(CCACHE_PROGRAM)

0 commit comments

Comments
 (0)