[CMake] Querying project dependencies from the UNIX command-line

Johannes Zarl-Zierl johannes at zarl-zierl.at
Wed Jul 18 16:04:05 EDT 2018


Hi Ardi,

Am Mittwoch, 18. Juli 2018, 11:31:50 CEST schrieb ardi:
> For example, I'd like to type "somecommand /path/to/someproject" at
> the UNIX command line, and get this output:
> [...]
> Furthermore, if another command could show optional requisites, it
> would be really great: "anothercommand /path/to/someproject"
> 
> Project /path/to/someproject can optionally use the following when being
> built: 
> [...]
> So, can I get this functionality from plain CMake/CPack ? Or would I
> need additional tools (Note: I know about Hunter, but first I'd like
> to know if plain CMake does already offer this feature).

I don't think there's something that gives you exactly what you described, 
especially not for a random CMake project.

If you can add some commands to the CMakeLists.txt, though, then the 
FeatureSummary module may suit your needs.

Basically, you include the module an then add a cmake command like this:
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)

When you run cmake, you'll get a summary of which packages have been found/not 
found, and the required version if you supplied one for the corresponding 
find_package command.

Cheers,
  Johannes





More information about the CMake mailing list