How to install relevant shared libraries along with executionable using cmake

CPack is used to generate an installable RPM package of your application. And I think the issue lies there since CMake has no trouble finding OpenCV. In fact when I build the project this line gets printed to the terminal:
-- Found OpenCV: /usr/local (found version "4.8.0") found components: core imgcodecs imgproc