How to generate .pc (pkg-config) file supporting --prefix of the cmake --install?

@sera, @hsattler, I did make it work. It’s only I’m not sure if this is the best way to do it, since it seems somewhat verbose.

@hsattler, I know about that pkg-config behavior. In fact, you can have it on *nix as well by adding --define-prefix command-line argument. (Or block it on Windows by adding --dont-define-prefix.) I regrat that the --define-prefix behavior is not the default one on *nix as well.

@sera, @hsattler, I’m not sure what do you mean by “installing into a staging directory”. It seems to me that “staging” is done by using DESTDIR. (A good read on the topic is also 7.2.4 DESTDIR: Support for Staged Installs.)

Whereas the --prefix command-line argument to install step says:

Override the installation prefix, CMAKE_INSTALL_PREFIX.

So, it doesn’t seem to infer with staging done by DESTDIR. The only difference is that in this “mode” the CMAKE_INSTALL_PREFIX is provided not during generate step but instead during install step.

If that would “break installing” then why do we have the --prefix command-line argument in the install step? Or why the configure_package_config_file command explicitly addresses this issue?