[CMake] Problem with generated source and header files
Tyler Roscoe
tyler at cryptio.net
Mon Jun 29 16:25:25 EDT 2009
On Mon, Jun 29, 2009 at 08:24:12PM +0200, Jörg Förstner wrote:
> The sequence of the build process shall be:
> 1. Go to build directory and execute "cmake <source-path>"
> 2. Execute "make"
> 3. The generator shall be called (but only if the source and header files are not yet generated).
> 4. The generator creates source and header files in folder 'generated'.
> 5. The source and header files in folder 'generated' shall be compiled.
> 6. The source and header files in folder 'generated' shall be added to library "libxyz.generated.so"
> 7. The library "libxyz.so" shall be built. "libxyz.so" shall be dependent on "libxyz.generated.so". The library "libxyz.generated.so" shall be linked to "libxyz.so".
I don't know if linking multiple shared libraries together like that is
going to work. You might need to compile libxyz.generated as a static
lib.
> The following attempt does not work, because the subdirectory "generated" is still empty, when FILE is called:
Right, because file() is run at CMake time but you need to work with
files generated at make time.
> FILE( GLOB SRCS ${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp )
> ADD_LIBRARY( xyz.generated SHARED ${SRCS} )
> ADD_DEPENDENCIES( xyz.generated generate_files )
I can't think of a good way to do this (it seems to me you'd have to
generate the list at make time and then somehow interpolate the list
into the already-written Makefile -- sounds ugly).
Can you change how you use the generator so that the files it writes
have predictable names?
tyler
More information about the CMake
mailing list