[CMake] Recover help text from option() ?

Petr Kmoch petr.kmoch at gmail.com
Wed Oct 9 03:57:36 EDT 2019


Hi Ellon.

On Wed, 9 Oct 2019 at 09:51, Ellon Paiva <ellonpaiva at gmail.com> wrote:

> Hi there,
>
> I was wondering if there was a way to recover the help text passed to an
> option to be used later below in the same CMake script.
>
> I saw that the help text goes into a comment before the option on the
> CMakeCache.txt, but is it stored in any recoverable variable during the
> script processing ?
>
>
Since option() just creates a cache variable, you should be able to
retrieve that variable's HELPSTRING property (
https://cmake.org/cmake/help/latest/prop_cache/HELPSTRING.html ):

  option(SampleOpt "Help")
  get_property(result CACHE SampleOpt PROPERTY HELPSTRING)

Petr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20191009/06c2f058/attachment.html>


More information about the CMake mailing list