Use local libraries but fall back to system wide if the local ones don't exist

Hi. This may sound a bit weird, so let me elaborate:

I am currently trying to create a project that uses GMP (libgmp and libgmpxx). If I were to only compile this under linux I’d just add the compiler flags -lgmpxx -lgmp, but I’m trying to make it compile under Windows too and also allow the user to provide their own binaries (if they have created more optimized versions for their particular machine for example).

So my idea was to declare them as precompiled libraries and provide dirs where the use can put the headers and binaries if they wish to use their custom ones, and fall back to the system wide libs if no local ones are provided.

My current approach looks like this:

However that naturally only works if the lib files are found in /usr/lib/x86_64-linux-gnu/. Also it currently doesn’t use the right dir for the headers.
But since compilers like gcc find system wide headers anyways it stll compiles.

So I think if I could provide a dir instead of a direct path for the static binaries (like I can do with the headers) it should work like I want it to. Then the compiler would just use the system wide stuff if there’s nothing in the dirs, but would use them if they are there.

I still would like a solution to that issue. I haven’t been able to figure this out except provide a fixed system path.