CMake Powershell tests
Some CMake tests need to use shell redirection to input file content.
This is often done on Unix-like systems by invoking sh -c
.
Powershell can also work (including on Windows) if proper escaping is used:
find_program(PWSH NAMES pwsh powershell)
if(PWSH)
add_test(NAME test1
COMMAND ${PWSH} -c \"Get-Content ${CMAKE_CURRENT_SOURCE_DIR}/myfile.txt | $<TARGET_FILE:myexe>\")
elseif(UNIX)
add_test(NAME test1
COMMAND sh -c "$<TARGET_FILE:myexe> < ${CMAKE_CURRENT_SOURCE_DIR}/myfile.txt")
endif()