2012/3/8 Glenn Ramsey <g...@componic.co.nz>: > Yes, you can use add_custom_command(...) to run a script to get the revision > number, but I don't think you can use that to alter CPACK_PACKAGE_FILE_NAME, > which has been set at cmake time.
This true but how wouldn't a revision update trigger a CMake re-run? Whatever the reason if you want to change/alter/set a CPACK_xxx value at CPack time , independently of CMakre re-run, you can use a CPACK_PROJECT_CONFIG_FILE: CPACK_PROJECT_CONFIG_FILE CPack-time project CPack configuration file. This file included at cpack time, once per generator after CPack has set CPACK_GENERATOR to the actual generator being used. It allows per-generator setting of CPACK_* variables at cpack time. In your CMakeLists.txt you have to: set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/MyCPackConf.cmake) then write the logic you want in MyCPackConf.cmake. see: http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#Overall_usage_.28common_to_all_generators.29 This CPACK_PROJECT_CONFIG_FILE is a CMake script file loaded by CPack (which includes a CMake script interpreter) you cannot use non scriptable CMake command in there (and no add_xxx to make it simple) but you can perfectly use execute_process in order to run some SCM commands. You should be able to override CPACK_PACKAGE_FILE_NAME dynamically in there. You have access to all CPACK_xxx variable value. However, in this script file you do not have access to CMAKE_xxx variables you can usually access in CMakeLists.txt (no CMAKE_PROJECT_NAME, nor orther variables YOU defined in the CMakeLists.txt besides CPACK_xxx ones) If you need some of these values you'll have to create a MyCPackConf.cmake.in which will be configured **at CMake-time** into MyCPackConf.cmake CMake itself is using this with the "CMakeCPackOptions.cmake.in" file at the root of CMake sources. -- Erk Le gouvernement représentatif n'est pas la démocratie -- http://www.le-message.org -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake