[CMake] File concatenation in cmake add_custom_command()
Ravi Raman
ravi.raman at Xoriant.Com
Mon Aug 25 01:36:34 EDT 2014
Hi David,
We have a query regarding file concatenation in cmake
First the details of what we have done:
Input Files: main.h, main.c
Copy Right file: copyright.txt
Output Files: mainWithCopyRight.c, mainWithCopyRight.h
Please find attached herewith a zip file containing the logic that we have used in cmake to perform file concatenation. It works successfully.
The requirement is that we have to do this in the cmake function add_custom_command()
We have done this as follows:
1. There is one CMakeLists.txt file for the source file main.cpp and header file main.h
2. Functions.cmake containing the function ac_prepend_copyright() which has the file concatenation logic
3. In the user-defined function ac_prepend_copyright():
1. First created a temporary fileconcat.cmake file which has the required FILE operations logic
2. In the add_custom_command() function call used the -D and -P options accordingly.
4. Invoked the function ac_prepend_copyright() from CMakeLists.txt
Note that the files mainWithCopyRight.c, mainWithCopyRight.h contain the contents of copyright.txt at the beginning followed by the source contents.
So, this works fine.
Query:
Is there a simpler way of performing file concatenation in cmake?
Thanks & Regards
Ravi Raman
Xoriant Solutions Pvt. Ltd
4th Floor, Winchester, Hiranandani Business Park, Powai, Mumbai 400076, INDIA.
Tel: +91 22 30511000,9930100026 Extn: 2144 Voip No. 4088344495/96/97/98 Voip Extn:1178| Fax: +91 22 30511111
ravi.raman at xoriant.com<mailto:ram.singh at xoriant.com>| http://www.xoriant.com<http://www.xoriant.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140825/d60d444f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FileConcat.zip
Type: application/x-zip-compressed
Size: 1693 bytes
Desc: FileConcat.zip
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140825/d60d444f/attachment.bin>
More information about the CMake
mailing list