It seems that cmake_dependent_option does not work with complex conditionals. For example:
OPTION(OPT1 "Option 1" ON)
OPTION(OPT2 "Option 2" ON)
OPTION(OPT3 "Option 3" OFF)
# Complex condition in if statement
IF (OPT1 AND (OPT2 OR OPT3))
MESSAGE("true")
ELSE()
MESSAGE("false")
ENDIF()
# Same condition in CMAKE_DEPENDENT_OPTION doesn't work
CMAKE_DEPENDENT_OPTION(DEP_OPT "dependent option" OFF "OPT1 AND (OPT2 OR OPT3)" OFF)
MESSAGE("DEP OPT = ${DEP_OPT}")
The issue is the macro converts each space to a “;” before using the conditional. This step breaks up the complex conditional.
The documentation mentions that “Each element in the fourth parameter is evaluated as an if- condition”.
This implies that more complex conditionals (besides the implicit AND of the list) will not work?
Am I missing some way of constructing the depends argument?