Does the CPack IFW Generator always include the module CPackIFW?

The doc page “CPack IFW Generator”, section “Hints”, says:

“Generally, the CPack IFW generator automatically finds QtIFW tools …”

Does that imply that the IFW generator always includes the module CPackIFW?

1 Like

Yes, CPackIFW is always included in the IFW generator. IFW generator is part of CMake. Both the generator and the module cannot be extended or replaced. But this is not what the hint sais.

The hint sais that CMake automatically finds QtIFW tools if they are installed on a default location on your machine. Otherwise you have to define an appropriate CMake or an environment variable.

Thank you & excuse me please: I am still confused.

Would it make sense to have the following three lines in a CMakeLists.txt:

set(CPACK_GENERATOR IFW)
include(CPack)
include(CPackIFW)

Or is the third line always redundant? When is CPackIFW automatically included: when running cmake or when running cpack -G IFW? When should the presence of QtIFW tools be checked: at cmake or at cpack time? Would the generator even notice location variables set at cmake time?

@jwuttke Yes,

By the first line you define the package generators you would like to use.
The second line makes use of the packaging functionality. It provides many generators like zip, tgz, etc.
The third line includes CPackIFW, this is a helper package for QtIFW tools. You could certainly manually set all configurations on CPack without including CPackIFW. CPackIFW is not essential to work with CPack and QtIFW tools, it simply makes live easier.

The 3rd line can be redundant, if you invest enough work into making it redundant.
CPackIFW is always included at configure time for CMake. To do that automatically CPackIFW must be used. To do it manually CPackIFW cannot be used (because you are being fancy and deliberately chose not to :wink:). Package is automatically dependent on build, so even if you do not build your project and run cmake --build . --target package it is going to build your project first.

If you run cpack -G IFW it will be a failure because the files to package do not exist. You have to build your project first!

No, the generator does not notice location variables set with CMake. Doing that is CMake’s job, you do not need to worry about it. CMake provides all information for the generator at configure time in a way the generator understands.

Conclusion: CPackIFW is an interface for QtIFW tools. You can focus on CMake and do not need to worry about how QtIFW works. Without CPackIFW you need to know how QtIFW tools work and make an interface for CMake.

Empirically, I cannot confirm. After removing include(CPackIFW) from CMakeLists.txt, leaving only set(CPACK_GENERATOR "IFW") and include(CPack), the commands cmake ..; make; cpack still generate a Qt installer.

And even after removing the set command from CMakeLists.txt, the commands cmake ..; make; cpack -G IFW still generate a Qt installer.

So I see no need for explicitly including the CPackIFWmodule.

The CPackIFW module provides a number of commands, such as cpack_ifw_configure_component(), cpack_ifw_configure_component_group(), cpack_ifw_add_repository() etc. If you want to call these functions, you should include the CPackIFW module.