The library provided by your distribution is old and you want to link your program to a more recent version.
Furthermore, I assume both the library you need and your program employ CMake as a build tool.
As an example, I’ll use openbabel for the library, while the project is called molecular-ribbon-builder.
I keep binary stuff in
~/opt (yeah I know, so much for the FHS), while the projects source is in
cd ~/progetti/openbabel mkdir build && cd build cmake -DCMAKE_INSTALL_PREFIX=~/opt .. make -j4 make install
Tell CMake where to find the newly installed library at compilation time
cd ~/progetti/molecular-ribbon-builder mkdir build && cd build CMAKE_PREFIX_PATH=~/opt cmake ..