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