CMake 3.18 - Feature suggestion: New option for install(CODE ...)


I would like to install code at the beginning of the cmake_install.cmake script.
But, to do that an option BEFORE or PREPEND which indicated that the code should be put at the beginning of the install script is necessary.
Do you think it would be possible to have such an option for install(CODE …)?

Thank you in advance for your reply.

Best regards,

Aymeric Pellé

Are you saying that your install scripts has dependencies which require one command to be executed before another?

Is it possible to handle this dependency before installation, during configuration or build?

If you need your install(CODE) to run earlier, move it before other install() commands. For example, instead of:

install(TARGETS foo DESTINATION bin)
install(CODE "# Code here")


install(CODE "# Code here")
install(TARGETS foo DESTINATION bin)
1 Like