set_if_not_set

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

set_if_not_set

Bill Newcomb
My top-level CMakeLists.txt files always end up with a lot of

if(NOT_DEFINED foo)
     set(foo bar)
endif()

things to allow people to pass interesting things on the command line or
to write their own "set this and that" CMakeLists.txt and include the
top-level one.

It would improve readability to have set_if_not_set and friends from
CTest.cmake available in a separate module or, better still, as language
primitives, either as-is or like

set(IF_NOT_SET foo bar)

or maybe

set(foo bar IF_NOT_SET)

Obviously I could define set_if_not_set at the top of each top-level
CMakeLists.txt, but the above would be nicer.

What do you think?

Thanks,
B.

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: set_if_not_set

Konstantin Tokarev


15.02.2017, 20:08, "Bill Newcomb" <[hidden email]>:

> My top-level CMakeLists.txt files always end up with a lot of
>
> if(NOT_DEFINED foo)
>      set(foo bar)
> endif()
>
> things to allow people to pass interesting things on the command line or
> to write their own "set this and that" CMakeLists.txt and include the
> top-level one.
>
> It would improve readability to have set_if_not_set and friends from
> CTest.cmake available in a separate module or, better still, as language
> primitives, either as-is or like
>
> set(IF_NOT_SET foo bar)
>
> or maybe
>
> set(foo bar IF_NOT_SET)
>
> Obviously I could define set_if_not_set at the top of each top-level
> CMakeLists.txt, but the above would be nicer.
>
> What do you think?

Use options or CACHE variables, default values will be set unless user specifies them
explicitly.

>
> Thanks,
> B.
>
> -----------------------------------------------------------------------------------
> This email message is for the sole use of the intended recipient(s) and may contain
> confidential information. Any unauthorized review, use, disclosure or distribution
> is prohibited. If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> -----------------------------------------------------------------------------------
> --
>
> 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:
> http://public.kitware.com/mailman/listinfo/cmake

--
Regards,
Konstantin
--

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:
http://public.kitware.com/mailman/listinfo/cmake