[CMake] Using a custom preprocessor

Hendrik Sattler post at hendrik-sattler.de
Mon Aug 18 04:08:51 EDT 2014



On 18. August 2014 09:20:26 MESZ, Petr Kmoch <petr.kmoch at gmail.com> wrote:
>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
>)

The foo.fs should also appear here. It is a source file and listing it improves behavior for e.g. Visual Studio.

>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
>>
>
>
>------------------------------------------------------------------------



More information about the CMake mailing list