[CMake] Problem with generated source and header files

Marcel Loose loose at astron.nl
Tue Jun 30 03:09:05 EDT 2009


Hi Joerg,

Is there a fixed, predictable relation between the input file(s) to the
generator and the output file(s) that are generated; like with Bison or
Flex?
If that's the case you can construct the list of files to be generated
from the list of input files to the generator. If the list of input
files is not known a priori, you might use globbing (assuming it will be
known once CMake is being run), but avoid that if possible, because it
hinders CMake's dependency analysis.

Best regards,
Marcel Loose.

On Mon, 2009-06-29 at 13:25 -0700, Tyler Roscoe wrote:
> 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
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list