Skip to content

CMakeLists.txt: read version from version.mak instead of hardcoding it#4896

Open
Copilot wants to merge 3 commits intomasterfrom
copilot/update-version-number-cmakelists
Open

CMakeLists.txt: read version from version.mak instead of hardcoding it#4896
Copilot wants to merge 3 commits intomasterfrom
copilot/update-version-number-cmakelists

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

CMakeLists.txt had VERSION 2.15 hardcoded, causing it to drift from the authoritative version defined in version.mak (currently 2.16).

Description

Parse PJ_VERSION_MAJOR, PJ_VERSION_MINOR, and PJ_VERSION_REV from version.mak at configure time and pass the result to project():

file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/version.mak" _version_lines)
foreach(_line IN LISTS _version_lines)
  if(_line MATCHES "^export PJ_VERSION_MAJOR[ \t]*:=[ \t]*([0-9]+)")
    set(_pj_ver_major "${CMAKE_MATCH_1}")
  elseif(_line MATCHES "^export PJ_VERSION_MINOR[ \t]*:=[ \t]*([0-9]+)")
    set(_pj_ver_minor "${CMAKE_MATCH_1}")
  elseif(_line MATCHES "^export PJ_VERSION_REV[ \t]*:=[ \t]*([0-9]+)")
    set(_pj_ver_rev "${CMAKE_MATCH_1}")
  endif()
endforeach()
# CMake VERSION field only accepts numeric components
if(_pj_ver_rev)
  set(_pj_cmake_version "${_pj_ver_major}.${_pj_ver_minor}.${_pj_ver_rev}")
else()
  set(_pj_cmake_version "${_pj_ver_major}.${_pj_ver_minor}")
endif()

project(pjproject VERSION ${_pj_cmake_version} ...)

version.mak is already the single source of truth for versioning (used by setup.py). The suffix (e.g. -dev) is intentionally excluded since CMake VERSION only accepts numeric components.

Motivation and Context

CMakeLists.txt version was stale (2.15 vs 2.16) and would require manual synchronization on every release. This change eliminates that toil.

How Has This Been Tested?

Verified cmake -S . -B build produces CMAKE_PROJECT_VERSION=2.16 matching version.mak.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the CODING STYLE of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI linked an issue Mar 30, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Update version number in CMakeLists.txt from version.mak CMakeLists.txt: read version from version.mak instead of hardcoding it Mar 30, 2026
Copilot AI requested a review from sauwming March 30, 2026 07:38
@sauwming sauwming marked this pull request as ready for review March 30, 2026 08:10
@sauwming sauwming requested a review from nanangizz March 30, 2026 08:12
@sauwming sauwming added this to the release-2.17 milestone Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Old version number in CMakeLists.txt

3 participants