CPack: - Run preinstall target...

I have a project that takes about 15 mins to build on Windows using the Intel fortran compiler. I have added the required files to create an Inno setup installer. Using the NMake Makefiles generator, building and running cpack from the build directory with the command line --config CPackConfig.cmake results in

CPack: Create package using INNOSETUP
CPack: Install projects
CPack: - Run preinstall target for: MyProject
CPack: - Install project: MyProject []
CPack: Create package
CPack: - package: G:/MyBuild_NMake/MyProject-2024.02.20-win32.exe generated.

where after the line CPack: - Run preinstall target for: MyProject there is a delay of 15 minutes while the whole project is silently rebuilt.
However, using the Visual Studio 15 2017 generator, building and running cpack I don’t get the CPack: - Run preinstall target for: line and the installer is created in the time it takes InnoSetup to run. Any suggestions as to what might be happening and/or how I can prevent the preinstall target being run?

There’s the install/fast rule in Makefiles generators. This basically just runs the install scripts without trying to bring the build up-to-date. I don’t know if Visual Studio generators make such a target; it may be useful and worth an issue.

That seems to be the opposite of what is happening. The NMake Makefiles generator causes CPack to run the preinstall target, which is presumably what is causing the rebuild, whilst the Visual Studio generator results in CPack creating the installer directly. Is there a way of forcing the install/fast rule?

The NMake generator should have /fast targets AFAIK. @brad.king?

CPack checks if the CMake generator has a preinstall target and drives it if so. Only Makefile generators have a preinstall target. It’s meant for re-linking binaries on platforms that support RPATH/RUNPATH fields, but using executable formats that CMake doesn’t know how to edit, in order to produce binaries with the install-tree runtime path values. VS generators don’t support targeting any such platforms and so do not have a preinstall target. The Ninja generator just never supported those platforms, and these days CMake knows how to edit both ELF and XCOFF formats.

If a build is up to date, the preinstall target should not cause a full rebuild. That’s something to track down locally.