[CMake] set_if_not_set

Bill Newcomb bnewcomb at nvidia.com
Wed Feb 15 11:43:53 EST 2017


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


More information about the CMake mailing list