[CMake] Recover help text from option() ?

Ellon Paiva ellonpaiva at gmail.com
Wed Oct 9 05:11:01 EDT 2019


Hi Petr,

On Wed, Oct 9, 2019, 09:57 Petr Kmoch <petr.kmoch at gmail.com> wrote:

> 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)
>

Awesome, thanks!

Another somehow related question: is there a way to recover the name of all
options defined in a project?

Ellon



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


More information about the CMake mailing list