[CMake] How to configure target or command to preprocess C file?

Mateusz Loskot mateusz at loskot.net
Wed Jul 11 17:38:26 EDT 2012


On 9 July 2012 08:17, Petr Kmoch <petr.kmoch at gmail.com> wrote:
> [...]
> You have to create a custom command (using the OUTPUT signature) to
> actually do the preprocessing. If you're targetting gcc and Visual
> Studio, the command could look something like this:
>
> add_custom_command(
>   OUTPUT myfile.sql
>   COMMAND "${CMAKE_C_COMPILER}" -E myfile.sql.in -I ../common
>   MAIN_DEPENDENCY myfile.sql.in
>   COMMENT "Preprocessing myfile.sql.in"
>   VERBATIM
> )
>
> [..]
> Now you need something to "drive" this command.
> [...]
>
> add_custom_target(
>   ProcessSQL ALL
>   DEPENDS myfile.sql
>   COMMENT "Preprocessing SQL files"
>   VERBATIM
> )

Hi Petr,

Your solution is perfect fit for my problem.
Thank you for the great explanation!

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net


More information about the CMake mailing list