Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the CPack preinstall target do

Tags:

cmake

cpack

deb

I have a fairly complicated project that builds using CMake. The project uses CPack to generate .deb packages. When I just build the project with make (i.e. not building a .deb) a clean build takes roughly 2 minutes. However when I build a package using make package the build takes roughly 12 minutes, with most of the the extra 10 minutes spent during CPack: - Run preinstall target for....

Building a .deb "manually" using dpkg-deb takes a couple seconds at most, so I'm wondering what CPack is doing when it's running the preinstall target.

I'm not necessarily interested in why it takes a long for my project specifically. I'm more curious about how the preinstall target fits into CPack's process of building a Debian package and how CPack chooses what actions will be taken when running the preinstall target.

like image 855
shay Avatar asked Feb 09 '18 17:02

shay


1 Answers

As far as I can tell from the CMake Mailing List and this related question, the 'preinstall target' tries to rebuild your entire project, except without logging any build output to stdout. (And likely without any flags to enable parallelism either)

Apparently, this only happens if the CMake Generator / CPACK_CMAKE_GENERATOR you are using is Unix Makefiles, and is the result of CMake install commands not carrying any target dependency information with them.

One possible workaround is lying to CPack about what generator you're using, for example by setting CPACK_CMAKE_GENERATOR to Ninja.

like image 61
AlanR Avatar answered Oct 13 '22 07:10

AlanR