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] [EMAIL PROTECTED])

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.

--
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Jul 29, 2008, at 11:22 AM, Markus Grabner wrote:


        Hi!

How can I write a custom command to create a source file which doesn't appear in the source file list of any target, but is included in another
source file? Consider a file "file1.c", from which "file2.c" should be
generated automatically whenever "file1.c" has been modified. However,
both "file1.c" and "file2.c" are just code snippets which can't be compiled into separate object files, but must instead be included in "file3.c" like
this:

void func1() {
#include "file1.c"
}

void func2() {
#include "file2.c"
}

So only "file3.c" contains syntactically valid C code (after preprocessing, i.e., including "file1.c" and "file2.c"), while "file1.c" and "file2.c" by
themselves don't. Now the corresponding target would be

add_executable(file3 file3.c)

According to [1] and [2], the file to be generated should appear in the source list of a target. However, this is not possible here since it would result in a compile error. The "add_dependencies" command [3] also doesn't help since
it can only be used for top level targets, but not for the output
of "add_custom_command".

Since writing such rules in plain Makefile syntax by hand is trivial, I believe that cmake should also support this situation, but I just can't
figure out how. Are there any ideas how to solve this?

        Thanks & kind regards,
                Markus


[1]
http://www.cmake.org/HTML/cmake-2.6.html#command:add_custom_command

[2]
http://www.cmake.org/Wiki/ CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F

[3]
http://www.cmake.org/HTML/cmake-2.6.html#command:add_dependencies

--
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
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake



_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to