[CMake] Defer compiler to different file in Visual Studio
Bill Hoffman
bill.hoffman at kitware.com
Mon Mar 12 16:36:06 EDT 2012
On 3/12/2012 3:28 PM, Andreas Haferburg wrote:
> Hello,
>
> I'm currently evaluating Lazy C++ [1], which generates both header and
> source files. I'm using add_custom_command() to invoke the generator on
> *.lzz file, and for each .lzz file it generates one .hpp file and one
> .cpp file. What I'm missing is the ability to compile the file I'm
> currently editing from within Visual Studio.
>
> With .cpp files it's possible to compile just one file, e.g. by
> right-clicking it in the Solution Explorer, then selecting "Compile". Or
> even better, bind it to a hotkey.
>
> So what I'd like to do is for each lzz file, set the compile command to
> compile the corresponding cpp file. I can't imagine it being that hard,
> since one would merely have to change the file extension in the command
> line from cpp to lzz. Any ideas?
>
> I'm not sure though, this might be more of a Visual Studio-specific
> question than a CMake-specific one.
Lzz is not a compiler, but rather a code generator. I would set things
up so that you do something like this:
create_lzz_source_list(MY_CPP_HH_SOURCES foo.lzz bar.lzz car.zzz)
add_library(mylib ${MY_CPP_HH_SOURCES})
# create_lzz_sources would be a function that creates a bunch of custom
commands that run lzz on each lzz input file and create a .cpp and .hh
file. So, there should be a custom command for each .cpp and .hh file.
You should be able to click on one of those can select compile, and it
will run that file.
This is the exact type of thing that is done for the VTK code wrapper code.
-Bill
More information about the CMake
mailing list