[CMake] Technique for generating projects that depend on generated sources

Steve Huston shuston at riverace.com
Fri Feb 27 08:01:29 EST 2009


Thanks for the advice, Bill.

My situation is somewhat different, though. The output source files
are not known ahead of time. Thus, the general scheme is:

- build runs the source generator; one of the outputs is a file
containing the names of the generated sources.
- rerun cmake to regenerate the build now that the complete list of
sources is known.
- rerun the build with the complete set of sources

I tried to make that all happen automatically in the build.

-Steve

--
Steve Huston, Riverace Corporation
Check out my networked programming blog at
http://stevehuston.wordpress.com/


> -----Original Message-----
> From: Bill Hoffman [mailto:bill.hoffman at kitware.com] 
> Sent: Thursday, February 26, 2009 9:04 PM
> To: Steve Huston
> Cc: cmake at cmake.org
> Subject: Re: [CMake] Technique for generating projects that 
> depend on generated sources
> 
> 
> Steve Huston wrote:
> > I'm working on a project that involves generating a large 
> chunk of the
> > sources from separate definitions. The set of generated source
files
> > is not known before it is generated.
> > 
> > The approach I've tried so far (and I'm very new to cmake) is to
> > define a custom_command that does the source generation, then run
> > cmake over again to regenerate the project files.
> > 
> > I tried this out with Microsoft Visual Studio... When I 
> tried a build
> > from inside Visual Studio the command to generate the 
> sources happened
> > like I want, but when it tried to re-run cmake to regenerate the
> > project with the now-known set of generated sources, an error was
> > thrown because cmake couldn't update VS macros while VS is
running.
> > 
> > So close, yet so far... ;-)
> > 
> > Is there a common pattern for how to address this type of
situation?
> > 
> 
> Look at the FAQ:
> 
> http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_generate_an_execu
table.2C_then_use_the_executable_to_generate_a_file.3F

-Bill



More information about the CMake mailing list