title: How to call a cmake method from shell script?
body: <p>I have a parameterised function in <code>mytestprogram.cmake</code> written like below:</p>
  <pre><code>function(get_output_from_input output input) 
      set(${output} &quot;test&quot; PARENT_SCOPE)
  endfunction()
  </code></pre>
  <p><strong>Question:</strong><br />
  How do I call the cmake method <code>get_output_from_input</code> from a shell script?</p>
  <p>I learnt that there is <code>-P &lt;source.cmake&gt;</code> flag, that puts CMake into script processing mode and we can execute arbitrary CMake code with it using something like below.</p>
  <pre><code>execute_process(COMMAND ${CMAKE_PROGRAM} -P yourscript.cmake)
  </code></pre>
  <p>So, in this case I believe the way to call <code>get_output_from_input</code> from a shell script would be something like below?</p>
  <pre><code>input=&quot;some_input&quot;
  output=&quot;&quot;
  execute_process(get_output_from_input(output, input) ${CMAKE_PROGRAM} -P mytestprogram.cmake)
  echo $output
  </code></pre>
  <p>But above trick does not work. Is the way I am running <code>execute_process</code> correct?</p>
  <p>Trying to figure out whats wrong, it seems <code>echo $CMAKE_PROGRAM</code> returns empty? Could that be the reason? What am I missing here to call <code>get_output_from_input</code>?</p>
  <p><strong>Environment:</strong><br />
  cmake version 3.18.2<br />
  macOS Catalina</p>