Overriding CPack version from command line not working

According to the docs, using cpack -R <version> should override whatever CPACK_PACKAGE_VERSION has been previously deduced/configured. Except as far as I can tell, it doesn’t…

-R <packageVersion>
Override/define the value of the CPACK_PACKAGE_VERSION variable used for packaging. It will override a value set in the CPackConfig.cmake file or one automatically computed from CPACK_PACKAGE_VERSION_MAJOR, CPACK_PACKAGE_VERSION_MINOR and CPACK_PACKAGE_VERSION_PATCH.

Am I missing something? :smiley:

Minimal reproducer

CMakeLists.txt

cmake_minimum_required(VERSION 3.25)
project(HELLO VERSION 1.2.3)

set(HELLO_SOURCE [[
#include <iostream>
int main()
{
  std::cout << "Hello, World!" << std::endl;
  return 0;
}
]])
file(WRITE "${CMAKE_BINARY_DIR}/hello.cpp" "${HELLO_SOURCE}")

add_executable(hello "${CMAKE_BINARY_DIR}/hello.cpp")
install(TARGETS hello)

include(CPack)

Then:

$ cmake --version
cmake version 3.25.0
$ cmake -S . -B build
...
-- Generating done
-- Build files have been written to: /Users/rcoup/tmp/cpack-ver/build
$ cmake --build build/
[ 50%] Building CXX object CMakeFiles/hello.dir/hello.cpp.o
[100%] Linking CXX executable hello
[100%] Built target hello

$ cd build
$ cpack -G ZIP
CPack: Create package using ZIP
CPack: Install projects
CPack: - Run preinstall target for: HELLO
CPack: - Install project: HELLO []
CPack: Create package
CPack: - package: /Users/rcoup/tmp/cpack-ver/build/HELLO-1.2.3-Darwin.zip generated.

$ cpack -G ZIP -R 2.3.4
CPack: Create package using ZIP
CPack: Install projects
CPack: - Run preinstall target for: HELLO
CPack: - Install project: HELLO []
CPack: Create package
CPack: - package: /Users/rcoup/tmp/cpack-ver/build/HELLO-1.2.3-Darwin.zip generated.