CPack adds a semicolon at the start of installation scripts when building RPM
When generating RPM with pre-install scripts (when using CPACK_RPM_PRE_INSTALL_SCRIPT_FILE variable) CPack generates spec file with extra semicolon in %pre section.
Source script file
X
Fragment of the generated .spec file
%pre
;X
The same issue is with other script types (post, postun, etc.) . That leads to uninstallable RPMs. Source of the problem is line 14 of Modules/Internal/CPack/CPackRPM.cmake. Two values are passed to set() that joins them with a semicolon.