Preparing minimalistic binary package for CI (use of cpack and disabling modules)

Hello,

I have two questions (for the background see below):

Question 1:
I would like to pack VTK binaries using CPack. But it seems, that it is not supported (or at least not considered) because I don’t see “include(CPack)” in CMakeLists.txt, and the verison somehow seems to be broken, once one runs cpack.

Simply adding the line “include(CPack)” at the end of the “CMakeLists.txt” did the trick (except versions, which is not very critical for me), and the binary package seems to work. But my question is: why is CPack not enabled? Are there any issues with it, or just nobody needed it?
(the exact change can be seen here: https://github.com/DmitrySemikin/vtk-mirror/commit/900c17ae0d17ba65155675b9afd0309e326bb468)

Question 2:
There is a nice possibility to disable modules by using CMake variables VTK_MODULE_ENABLE_VTK_moduleName. But the eproblem with this approach is, that if one needs to use only couple modules, then she/he needs to disable (or set to DONT_WANT) all the others. Besides, new modules will not be excluded by default. The question is: is there any possibility to disable all modules by default except for explicity specified ones.

Background
For my small project, which uses VTK I wanted to setup a CI, which for now just builds the project on linux. As the project is on GitHub, it seemed more or less logical to use GitHub Actions as a CI engine.

But to build the project I of course need VTK binaries. One solution would be to build VTK every time I build the project, but half an hour build of VTK to enable 10 seconds build of my project seems like an overkill… After some experimenting I found out, that I can create a binary package compatible with the environment used in CI, and I can make it relatively small by disabling most of the modules (currently the size is about 25M, which can be downloaded and unpacked in couple seconds by github actions). This is why I need to package the binaries (and cpack is the easiest way, if it works), and disable modules.

Just in case anyone is interested, how it was done, VTK was built in this repo (also using github actions to be sure, that the environment is the same): https://github.com/DmitrySemikin/vtk-mirror (branch: prepare-for-github-actions). The binaries generated by action were first published as artifact, then manually downloaded and published as release (I know, that I can be automated, but I don’t really need it).

Then in this repo: https://github.com/DmitrySemikin/das-mesh-workbench I just download the package with wget, unpack it and use for build while setting CMAKE_PREFIX_PATH to the extracted directory. Seems to work fine. The whole build takes about 1 minute, which I find acceptable.

Regarding Question 2, I don’t think it’s possible to set DONT_WANT for all modules in one go.

The best you could do I think is to use VTK_GROUP_ENABLE_<name>=DONT_WANT, for all groups. That way you only have to specify it for every group, not for every module (and new groups are added more seldom than modules). I may be wrong and there’s some hidden way to do it for all modules though. I think @ben.boeckel will know.

Looking at the CMakeLists.txt of VTK, it seems only the StandAlone and Rendering groups are turned on by default, so maybe it would be enough with something like

cmake \
    -DVTK_GROUP_ENABLE_StandAlone=DONT_WANT \
    -DVTK_GROUP_ENABLE_Rendering=DONT_WANT \
    -DVTK_MODULE_ENABLE_<the_module_you_need>=ON

to get the minimal VTK you need.

In the VTK-based projects that I know of, it is always the application that uses VTK creates the package and therefore only the application needs to include CPack.

@lassoan:
Thank you. I take it as “nobody except me ever wanted it” :).

You may want to take a look at F3D: https://gitlab.kitware.com/f3d/f3d

I would like to pack VTK binaries using CPack.

We took the easy way and built VTK statically for the release.

One solution would be to build VTK every time I build the project, but half an hour build of VTK to enable 10 seconds build of my project seems like an overkill… After some experimenting I found out, that I can create a binary package compatible with the environment used in CI, and I can make it relatively small by disabling most of the modules (currently the size is about 25M, which can be downloaded and unpacked in couple seconds by github actions). This is why I need to package the binaries (and cpack is the easiest way, if it works), and disable modules.

See our gitlab-ci. We use the cache of the buildbot to avoid rebuilding VTK everytime.

@mwestphal:
Thank you. Nice to have it as a reference - to see, which build customizations are also available (like e.g. VTK_LEGACY_REMOVE). But I still prefer explicit download. I am not sure, how exactly build caches are handled by different CI systems, but e.g. Travis-CI explicitly tells, that caches should not be used to cache build artifacts. And in GitHub actions I believe artifats are similar to build cache. But I prefer “release artifacts” because for them the retention policies are more obvious and the whole logic is more explicit and thus more clear (at least IMO).