cmake: Correctly set options to their DEFAULT_DISABLED values
The config_option helper was previously using cmake_dependent_option, which supposedly took a value to set the option to in the case where it was disabled. However, this only sets the value in the current function context, and not the cache. I do not understand why this is the case and it seems to make that functionality completely useless. This commit simply does the dependency checking itself and correctly sets the disabled value.
This commit is contained in:
parent
5e273cc7bd
commit
777f19645b
1 changed files with 14 additions and 2 deletions
|
|
@ -179,10 +179,22 @@ function(config_option optionname configname doc)
|
|||
if("${CONFIG_DEFAULT_DISABLED}" STREQUAL "")
|
||||
set(CONFIG_DEFAULT_DISABLED "${CONFIG_DEFAULT}")
|
||||
endif()
|
||||
if("${CONFIG_DEPENDS}" STREQUAL "")
|
||||
set(valid ON)
|
||||
if(NOT "${CONFIG_DEPENDS}" STREQUAL "")
|
||||
# Check the passed in dependencies. This loop and logic is inspired by the
|
||||
# actual cmake_dependent_option code
|
||||
foreach(test ${CONFIG_DEPENDS})
|
||||
string(REGEX REPLACE " +" ";" test "${test}")
|
||||
if(NOT (${test}))
|
||||
set(valid OFF)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
if(valid)
|
||||
option(${optionname} "${doc}" ${CONFIG_DEFAULT})
|
||||
else()
|
||||
cmake_dependent_option(${optionname} "${doc}" "${CONFIG_DEFAULT}" "${CONFIG_DEPENDS}" "${CONFIG_DEFAULT_DISABLED}")
|
||||
set(${optionname} "${CONFIG_DEFAULT_DISABLED}" CACHE INTERNAL "${doc}")
|
||||
endif()
|
||||
set(local_config_string "${configure_string}")
|
||||
if(${optionname})
|
||||
|
|
|
|||
Loading…
Reference in a new issue