[CMake] Using a custom preprocessor
Petr Kmoch
petr.kmoch at gmail.com
Mon Aug 18 03:20:26 EDT 2014
Hi Paul.
The straightfroward way to do thisis with custom commands:
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/foo.f
COMMAND custom_preproc foo.fs -o ${CMAKE_BINARY_DIR}/foo.f
MAIN_DEPENDENCY foo.fs
COMMENT "Custom-preprocessing foo.fs"
VERBATIM
)
add_executable(myexe
${CMAKE_BINARY_DIR}/foo.f
main.f90
)
Analogously with cs, of course. See documentation of add_custom_command()
for all options available.
Petr
On Fri, Aug 15, 2014 at 7:47 AM, Paul Anton Letnes <pa at letnes.com> wrote:
> 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
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140818/8ff4b48d/attachment.html>
More information about the CMake
mailing list