<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Arial, sans-serif" size="2">
<div>Hello,</div>
<div>&nbsp;</div>
<div>Has anyone thought about the possibility of adding return values from CMake functions?&nbsp; This would be a very useful language feature that the Trilinos CMake files would use everywhere.</div>
<div>&nbsp;</div>
<div>Here is an example use case.&nbsp; One problem with CMake is that it has very loose checking.&nbsp; For example, if I write:</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp; IF (MYVARABLE)</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp; ...</div>
<div>&nbsp;&nbsp; ENDIF()</div>
<div>&nbsp;</div>
<div>Instead of what I meant:</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp; IF (MYVARIABLE)</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp; ...</div>
<div>&nbsp;&nbsp; ENDIF()</div>
<div>&nbsp;</div>
<div>then my CMakeLists.txt file will not work correctly.&nbsp; What I have been doing is to instead write an ASSERT_DEFINED(...) macro and then use it as:</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp; ASSERT_DEFINED(MYVARIABLE)</div>
<div>&nbsp;&nbsp; IF (MYVARIABLE)</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp; ...</div>
<div>&nbsp;&nbsp; ENDIF()</div>
<div>&nbsp;</div>
<div>Of course the problem with this is that I could misspell one of the uses as:</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp; ASSERT_DEFINED(MYVARIABLE)</div>
<div>&nbsp;&nbsp; IF (MYVARABLE)</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp; ...</div>
<div>&nbsp;&nbsp; ENDIF()</div>
<div>&nbsp;</div>
<div>and I am back in the same situation.&nbsp; The problem is that I am duplicating the variable name.&nbsp; This is a fundamental software engineering issue that needs to be addressed in some way.</div>
<div>&nbsp;</div>
<div>What I would like to be able to write is a function like:</div>
<div>&nbsp;</div>
<div>&nbsp; FUNCTION(ASSERTDEF VARNAME)</div>
<div>&nbsp;&nbsp;&nbsp; IF(NOT DEFINED ${VARNAME})</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MESSAGE(SEND_ERROR &quot;Error, the variable ${VARNAME} is not defined!&quot;)</div>
<div>&nbsp;&nbsp;&nbsp; ENDIF()</div>
<div>&nbsp;&nbsp;&nbsp; RETURN(${VARNAME})</div>
<div>&nbsp; ENDFUNCTION()</div>
<div>&nbsp;</div>
<div>You could then use this function like:</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp; IF (${ASSERTDEF(MYVARIABLE)$)</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp; ...</div>
<div>&nbsp;&nbsp; ENDIF()</div>
<div>&nbsp;</div>
<div>Then, if I misspelled the variable name as:</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp; IF (${ASSERTDEF(MYVARABLE)}$)</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp; ...</div>
<div>&nbsp;&nbsp; ENDIF()</div>
<div>&nbsp;</div>
<div>I would get an error message and processing would stop immediately.</div>
<div>&nbsp;</div>
<div>Above, I assume that the syntax:</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp; ${SOMEFUNCTION(ARGS)}</div>
<div>&nbsp;</div>
<div>Is needed to get CMake to expect a return value from the function and then return it, just like it would return a variables value.</div>
<div>&nbsp;</div>
<div>How hard would it be to all return values from CMake functions in this way?</div>
<div>&nbsp;</div>
<div>Thanks,</div>
<div>&nbsp;</div>
<div>- Ross</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
</font>
</body>
</html>