Obtain compile and link flags for a package

I am looking for a way to get the compilation and linking flags for an installed CMake package (that can be found with find_package), and use them in a non-CMake project. Does CMake provide a reasonably simple way to do this?

I found the cmake --find-package option, but the documentation states that it should not be used. Also, it does not seem to work in all cases.

I am not looking for a universal solution that will print the flags for any package, merely a starting point to implement a solution that can get the flags for one particular package.

Your package must expose them in some way from the config file. Ideally via INTERFACE_* properties on imported target(s). Otherwise via variable.

ParaView has a tool which can extract out the information for its own package here. Something like this is the most robust way of doing it (but does require per-package logic).