I originally asked this question on the CMake mailing list: How do I configure target or command for a preliminary C file?
I am migrating the GNU Autotools- based build configuration to CMake, and I have to deal with C preprocessing to create the file.
The preprocessor input is an SQL file with preprocessor C directives used , such as #include "another.sql"etc.
Currently Makefileuses the following rule to create a simple file SQLas output:
myfile.sql: myfile.sql.in.c
cpp -I../common $< | grep -v '^
Thus, it myfile.sqlmeans one of the products of the assembly process, similar to shared libraries or executable files.
What CMake tools should be used to achieve the same effect?
I wonder if I should use add_custom_command, add_custom_targetor combine both.
Obviously, I'm looking for a portable solution that will work, at least with the GNU GCC and Visual Studio tools. I assume that I will have to define special commands for a particular platform, one for the preprocessor cpp, one for cl.exe /P.
Or, does CMake do any abstraction for the C preprocessor?
I looked through the archives, but I found only the preprocessing of fortran files or solutions based on the capabilities of make: make myfile.i
So this is not quite what I am looking for.
UPDATE: , Petr Kmoch CMake .