If I have the set(CPACK_PACKAGE_VERSION_MAJOR "2024-02-15")
in my CMakeLists.txt that does INCLUDE(CPack)
, then after I create the Makefile with cmake ../
, I can call make package
, and the resulting .deb file will have the specified version string in its filename.
I can also do execute_process( COMMAND date +'%Y-%m-%d' OUTPUT_VARIABLE CPACK_PACKAGE_VERSION)
and have the output of the date +'%Y-%m-%d'
written into the CMake CPACK_PACKAGE_VERSION
variable; however the command is only called once, at configure time, when cmake ../
is called – and the resulting output is hardcoded in CPackConfig.cmake
and CPackSourceConfig.cmake
.
What can I do, to have a Cmake variable – or even, a Makefile variable – be updated from the results of calling some external program, every time make
with some specific target (like make package
) is called?