add_dune_test: Handle complex expressions in `CMAKE_GUARD`
The check if(NOT ${condition})
does not behave as expected when
condition
is a complex string expression such as A OR B
. It does
however work when condition
is a list.
Therefore convert condition
to a list by calling separate_arguments
.
Note that this change also adds missing parenthesis around condition
which also results in wrong results for complex expressions.
Closes issue #39 (closed).
Merge request reports
Activity
@gruenich They seem to work if you write "( A OR B ) AND ( C OR D )" with spaces around the parenthesis, see the example CMake script below (run with
cmake -P ${foo}
). I don't know enough about CMake to explain why it is so strange.foreach(A 0 1) foreach(B 0 1) foreach(C 0 1) foreach(D 0 1) #message("A=${A} B=${B} C=${C} D=${D}") if(NOT ((A OR B) AND (C OR D))) message(true) else() message(false) endif() set(X "( A OR B ) AND ( C OR D )") # No spaces leads to unhappiness: #set(X "(A OR B) AND (C OR D)") separate_arguments(X) #message("X=${X}") if(NOT (${X})) message(true) else() message(false) endif() message(======) endforeach() endforeach() endforeach() endforeach()
Added 1 commit:
- 074f0993 - [cmake] Mention complex expression for CMAKE_GUARD in documentation
mentioned in commit 3d6dc19c
Sorry I did not reply to this, I was away for some days. Thanks @ansgar for fixing the mess I created there (although I will absolutely blame CMake's policy of handling lists...) The fix looks good, I did not know that
separate_arguments
existed.Mentioned in commit 3d6dc19c