I've written a small CMake module for, well, it doesn't matter what for. The point is that it acts as follows:
- When the appropriate CMake function is invoked, a shell script with relative path
scripts/whatever.sh
(under the project directory) is invoked. - The shell script
cat
's a 'here-file' containing a C program to the C compiler found by CMake (with fallback tocc
) - The program is compiled, linked and run, producing some text
- The output text is saved as a CMake variable
This is relatively robust on Unix-like systems, where cat
and bash
are available and when the path separator is /
. (There may be other assumptions I'm ignoring.) But - I want this to work on Windows, and other systems as well. How do I go about doing this?
Notes:
- In case it's relevant: The shell script and the CMake module.
- I can use C++ instead of C if that helps.