I’m attempting to add a cmake build system to an old fortran code that is littered with
!DEC$
style preprocessor commands. The old build system generated an awk script that converted these to the traditional C style preprocessor. The makefile would then just pipe the output directly to the compiler. I know with cmake that I can generate an intermediate file but I would like to avoid that if possible because I want to run this over every file.
Is there a method in cmake to pipe the output of a command directly to the compiler? Basically is there away to do the equivalent to
awk -f script.awk source.f | gfortran -x f95 -cpp -c -
in cmake.
You can add a cmake add_custom_command to run awk and save the output to another file, in which case there will be no need for piping. To have piping, I think a bash script can be written which includes the piped statement. The script can then be defined as the cmake compiler (Using a different compiler).