[CMake] custom command to create file #included in other file?

Markus Grabner grabner at icg.tugraz.at
Tue Jul 29 11:57:02 EDT 2008


Am Dienstag 29 Juli 2008 schrieb Mike Jackson:
> VTK does this all the time. You could try to take a look through the
> vtk source and try to figure out what is going on.
>
> Also,
>    You could try:
>
>   CONFIGURE_FILE(InputFile OutputFile
>                          [COPYONLY] [ESCAPE_QUOTES] [@ONLY])
>
> So..
> CONFIGURE_FILE(file1.h.in file1.h)
> CONFIGURE_FILE(file2.h.in file2.h)
>
> set (My_SOURCES
> 	file3.c
> )
> set (Generated_files
>         file1.h
> 	file2.h
> )
>
> #Include the path to the generated files
> INCLUDE_DIRECTORIES( "${PROJECT_BINARY_DIR}" )
> add_executable(MyApp ${My_SOURCES} ${Generated_files} )
>
>
> None of that is tested but _may_ work for your needs.
Thanks a lot for the hint! While this is not exactly what I was looking for 
(would have to rename the ".c" files to ".h"), it actually pointed me to a 
solution, namely declaring the files as "HEADER_FILE_ONLY" with 
the "set_source_files_properties" command and including them in the source 
list. It's a bit more verbose than I hoped it would be, but does the job.

	Kind regards,
		Markus


-- 
Markus Grabner - Computer Graphics and Vision
Graz University of Technology, Inffeldgasse 16a/II, 8010 Graz, Austria
Phone: +43/316/873-5041, Fax: +43/316/873-5050
WWW: http://www.icg.tugraz.at/Members/grabner


More information about the CMake mailing list