[CMake] install() rename with version string -solved-

Wagner Martin Martin.Wagner at neuberger.net
Fri Jan 20 07:16:58 EST 2017


Thank you very much! This did the trick

> 
> Well, the second install command has the wrong scope:
> install(CODE "include(version.cmake)")
> install(FILES firmware.hex
> RENAME  firmware_\${version_string}.hex
> DESTINATION firmware)
> 

I've tried that before, but without the firmware_---->\<-----${version_string}.hex escape. 
Looking at the generated cmake_install.cmake makes obvious why it needs to be escaped.

if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
  include(${CMAKE_BINARY_DIR}/version.cmake)
endif()

if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
  file(INSTALL DESTINATION "firmware.hex" TYPE FILE RENAME "firmware_${version_string}.hex" FILES "path.../firmware.hex ")
endif()


More information about the CMake mailing list