Setting default install permissions globally

I would like to be able to set global default install permissions, so I don’t have to either rewrite each and every install(...) command, or override it with a custom install(...) command in my project.

There already is the CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS variable for implicitly created dirs during installation.

The following additional variables could be added for all the different install command signatures:

  • CMAKE_INSTALL_DEFAULT_TARGET_ARCHIVE_PERMISSIONS for install(TARGETS ...)
  • CMAKE_INSTALL_DEFAULT_TARGET_LIBRARY_PERMISSIONS for install(TARGETS ...)
  • CMAKE_INSTALL_DEFAULT_TARGET_RUNTIME_PERMISSIONS for install(TARGETS ...)

In my project I could then just e.g. list(APPEND CMAKE_INSTALL_DEFAULT_TARGET_ARCHIVE_PERMISSIONS GROUP_WRITE)

I could also set the global install permissions in an initial cache file.

Another benefit would be the ability to change the install permissions of upstream projects on configuration.

Having variables to tell install() about default PERMISSIONS arguments sounds reasonable to me.

CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS is slightly distinct from that idea because it applies to cases where directories are implicitly created as part of preparing the DESTINATION for files in install() calls that only define permissions for the files themselves. The variables proposed here will modify the default permissions that install() otherwise defines already.