OK, I’ve solved this.
Because I had used configure_file to store the value of CMAKE_INSTALL_FULL_BINDIR in my generated file, but ‘sofiles’ had no value at this time, ‘${sofiles}’ was being set to an empty string.
The solution was simply to set the contents of scriptfile.cmake.in to:
execute_process(COMMAND ls @CMAKE_INSTALL_FULL_BINDIR@/../lib/python2.7/sil)
file(GLOB sofiles @CMAKE_INSTALL_FULL_BINDIR@/../lib/python2.7/sil/*.so)
message("sofiles contains ${sofiles}")
foreach (sofile ${sofiles})
message("Converting RPATH in ${sofile} to RUNPATH")
execute_process(COMMAND chrpath --convert ${sofile}
COMMAND_ECHO STDOUT)
endforeach()
…and invoke configure_file using the @ONLY option.