[CMake] Using a custom preprocessor

Paul Anton Letnes pa at letnes.com
Fri Aug 15 01:47:32 EDT 2014


Hi!

I am currently working on a project which uses plain old make as a build system. Needless to say, adding new compilers etc. is a lot of work, so I would like to start using CMake, which I have had excellent experience with in the past.

There is one peculiarity that I do not know how to handle. Some of our code (C and Fortran) is contained in files that end with .cs or .fs, which are run through an in-house preprocessor. A Makefile target is then something along the lines of (but not exactly)

foo.o: foo.f
    $(FC) -c $(FFLAGS) foo.f

foo.f: foo.fs
    custom_preproc foo.fs -o foo.f

Is it possible to, somehow, add this pre-compilation step for such files, and then
add_executable(myexe
    foo.fs
    bar.cs
    main.f90)
?

Cheers,
Paul


More information about the CMake mailing list