google / marl

A hybrid thread / fiber task scheduler written in C++ 11
Apache License 2.0
1.88k stars 194 forks source link

Difference between option_if_not_defined and option #223

Closed zhufangda closed 1 year ago

zhufangda commented 2 years ago

Hello, I am curious that @ben-clayton define a cmake function option_if_not_defined. But I have tested and found that option_if_not_defined and option have the same behavior. So can you tell me why did you do that. I found you use option_if_not_defined instead of option in 2019/11/20.

function (option_if_not_defined name description default)
    if(NOT DEFINED ${name})
        option(${name} ${description} ${default})
    endif()
endfunction()

cordialement zhufangda

ben-clayton commented 2 years ago

It prevents the CMakeCache.txt and any related GUI from listing a whole bunch of settings that may be explicitly specified by an outer project. This removes noise, and prevents conflicting combinations of settings required by outer projects.