Recover help text from option() ?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Recover help text from option() ?

Ellon Paiva
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 ?

Best,

Ellon
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Recover help text from option() ?

Petr Kmoch
Hi Ellon.

On Wed, 9 Oct 2019 at 09:51, Ellon Paiva <[hidden email]> 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

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Recover help text from option() ?

Ellon Paiva
Hi Petr,

On Wed, Oct 9, 2019, 09:57 Petr Kmoch <[hidden email]> wrote:
Hi Ellon.

On Wed, 9 Oct 2019 at 09:51, Ellon Paiva <[hidden email]> 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

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Recover help text from option() ?

Petr Kmoch
On Wed, 9 Oct 2019 at 11:11, Ellon Paiva <[hidden email]> wrote:
Another somehow related question: is there a way to recover the name of all options defined in a project?



You should be able to get this by reading the directory property CACHE_VARIABLES ( https://cmake.org/cmake/help/latest/prop_dir/CACHE_VARIABLES.html ) and going from there (querying variable types etc.), but note that it's "intended for debugging purposes." Please read the docs on cache variable properties ( https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-cache-entries ) to see what's possible.

Petr

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Recover help text from option() ?

Ellon Paiva
On 10/9/19 1:59 PM, Petr Kmoch wrote:
> You should be able to get this by reading the directory property
> CACHE_VARIABLES (
> https://cmake.org/cmake/help/latest/prop_dir/CACHE_VARIABLES.html )
> and going from there (querying variable types etc.), but note that
> it's "intended for debugging purposes." Please read the docs on cache
> variable properties (
> https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-cache-entries 
> ) to see what's possible.

Perfect, thanks again !

Ellon
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake