Skip to content

Set CMake project version based on config.inc #5458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
cmake_minimum_required(VERSION 3.2)

project(CBMC)

# Grab the current CBMC version from config.inc
# We do this so we have a matching cbmc version between the Makefile build and
# the CMake build. This version info is useful for things like generating
# packages (which usually need to contain version info in their metadata and
# filenames)
file(
STRINGS src/config.inc CBMC_VERSION
REGEX "CBMC_VERSION = (.*)")
string(REGEX REPLACE "CBMC_VERSION = (.*)" "\\1" CBMC_VERSION ${CBMC_VERSION})

project(CBMC VERSION ${CBMC_VERSION})

# when config.inc changes we’ll need to reconfigure to check if the version changed
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/config.inc")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a general query about this - when does config.inc get generated? IIRC it gets auto generated using the git info? If so, when does that change, and what is the effect here? I'm slightly worried about whether this means every time you make a local change and re-build, it also causes a fresh re-configure? And if so, doesn't that also mean a fresh re-download of minisat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisr-diffblue This string is static and currently only user set (plan is to autoincrement on release going forward). The git-tag string is also used but only for use in util/version.h, which uses both this info and the git-tag.

The reason we keep the two separate is to support builds from source packages and shallow clones. So this will not trigger frequent reconfigures.

As I believe I’ve mentioned before as well a long term goal of mine is for us to stop downloading things off the internet in our CMakeLists.txt at all and instead provide the dependency downloading/building stuff as a separate script.


find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
Expand Down