Can CMake / CPack generate multiple NSIS installers for a single project?

I have one project (with subprojects) for which I would like to generate several executable files of the NSIS installer, instead of having several components listed in the same NSIS installer. Is it possible? Or do I need to organize my code into separate projects?

+5
source share
1 answer

You can specify the CMake attribute, for example. COMPONENT , which can be set to a value from a predefined set of package names, such as: COMPONENT_1 | COMPONENT_2 | ... COMPONENT_X

The package name may even be a name that does not match the name of one component, but a set of components to be added to CPACK_COMPONENTS_ALL. If COMPONENT is ALL_COMPONENTS then CPACK_COMPONENTS_ALL will contain all possible components.

Packing box:

 if (WIN32) set (CPACK_COMPONENTS_ALL ${COMPONENT}) set (CPACK_PACKAGE_NAME ${COMPONENT}) set (CPACK_COMPONENT_${COMPONENT}_DISPLAY_NAME "${COMPONENT}") set (CPACK_COMPONENT_${COMPONENT}_DESCRIPTION "${COMPONENT}") set (CPACK_NSIS_DISPLAY_NAME "${COMPONENT}") set (CPACK_NSIS_PACKAGE_NAME "${COMPONENT}") set (CPACK_NSIS_INSTALL_ROOT "C:") set (CPACK_GENERATOR NSIS) else() ... endif() 

To create an installer for each COMPONENT component, follow these steps:

 cmake -COMPONENT=COMPONENT_1 ../ nmake package cmake -COMPONENT=COMPONENT_2 ../ nmake package ... cmake -COMPONENT=COMPONENT_X ../ nmake package 

Keep in mind that since binaries are created the first time nmake package , subsequent calls to cmake and nmake package will only nmake package packaging and only build the requested COMPONENT component (aka ACONENT)

0
source

Source: https://habr.com/ru/post/1232647/


All Articles