Only search for libapp and libjson when dynamically linking to them

Otherwise static build fails if they are not installed system-wide.
Include local libapp and libjson when static building