TriBITS icon indicating copy to clipboard operation
TriBITS copied to clipboard

Add support for project-level extra installs that works with custom group and permissions fixup support

Open bartlettroscoe opened this issue 4 years ago • 4 comments

Description

As described in trilinos/Trilinos#8870 some TriBITS projects may need to install files that are not in a single TriBITS package. Currently in Trilinos, this was done in the top-level CMakeLists.txt file after the tribits_project() command. The problem with that is that the custom group and permissions fixup functionality described in:

  • https://tribits.org/doc/TribitsBuildReference.html#setting-install-ownership-and-permissions

does not get run on these extra files and directories.

Implementation options

There are two general ways this problem could be addressed. First, the install permissions fixups could be run again in a function called at the end of the project's CMakeLists.txt file. But that is inconsistent with how the TriBITS framework works in general. TriBITS defines injection points for functionality by having the project define callback files that the framework processes.

The second approach is to define a callback file for this purpose. In the case of Trilinos, the files being installed (i.e. installing tribits and build-stats wrappers) are at the project level, not the repository level. So it should be a file that is designed for a project callback, not a repository callback. There already is the callback file <projectDir>/cmake/CallbackDefineProjectPackaging.cmake that is processed after all of the TriBITS package's CMakeLists.txt files are processed. But the problem with trying to put install commands is that file is that that file is only processes if ${PROJECT_NAME}_ENABLE_CPACK_PACKAGING is set to TRUE and we can do installs when not installing packing files (but agreed that would be rare).

The best option then is to define a new callback file called something like <projectDir>/cmake/CallbackDefineProjectExtraInstalls.cmake with a macro called TRIBITS_PROJECT_DEFINE_EXTRA_INSTALLS() that will be unconditionally included after all of the project's package's CMakeLists.txt files have been included. Also, this can take advantage of the the new CMake 3.14+ policy CMP0082 to refactor install-related code to not require installs to be done in subdirs.

bartlettroscoe avatar Mar 12 '21 15:03 bartlettroscoe

I have already spent a bunch of time looking into this as part of trilinos/Trilinos#8870. I think that I should just bite the bullet and get this done today and get it tested.

Most of the time implementing this will be in writing a strong test for this in TriBITS and writing up documentation. Writing the actual code should be easy.

bartlettroscoe avatar Mar 12 '21 15:03 bartlettroscoe

While creating PR #360, I realized that the only robust way to implement the custom install_package_by_package target is to have TriBITS run the install of extra custom project-level stuff. This is because it must be driven from a subdir where one can invoke the cmake -P cmake_install.cmake command in the install inside of a subdir in case a package fails to build and install. So that makes the choice of implementation easy. We have to define a callback file <projectDir>/cmake/CallbackDefineProjectExtraInstalls.cmake and it must be included inside of the file tribits/installation/add_project_install_command/CMakeLists.txt. That should be a piece of cake. (All of the real work will be adding an automated test and updating documentation.)

bartlettroscoe avatar Mar 13 '21 01:03 bartlettroscoe

Relates to my epic SEPW-215

bartlettroscoe avatar Mar 13 '21 15:03 bartlettroscoe

This sounds reasonable to me. Thank you for looking into this, @bartlettroscoe.

e10harvey avatar Mar 15 '21 13:03 e10harvey