[CMake] Defer compiler to different file in Visual Studio

Bill Hoffman bill.hoffman at kitware.com
Mon Mar 12 17:26:34 EDT 2012


On 3/12/2012 5:00 PM, Andreas Haferburg wrote:
> Yea, that's pretty much what I've got so far. And yes, I realize that's
> the way it's *supposed* to be set up. ;) I've posted my CMakeLists.txt
> here if you want to have a look:
> http://stackoverflow.com/a/9669388/872616
>
> The only time I would really like to have anything to do with generated
> files is if something goes wrong with the generation, but not during
> normal development. I'd like to set up the tool chain such that I only
> have to touch the .lzz files, and the .hpp/.cpp would be completely
> hidden away in the build dir. Just as normally you wouldn't want to have
> anything to do with .obj files, you know?
I don't think you can do that.   However, you can make it a little nicer 
with this change:

    MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${filename}"



 From
Note that MAIN_DEPENDENCY is completely optional and is used as a 
suggestion to visual studio about where to hang the custom command.  In 
makefile terms this creates a new target in the following form:

cmake --help-command add_custom_command

          OUTPUT: MAIN_DEPENDENCY DEPENDS
                  COMMAND

However, when you right click on A.lzz and it will run lzz, and not the 
full compiler cycle.  You will have to right click on the generated .cpp 
file to run the actual compiler.  There is no way to collapse that into 
one step.

-Bill



More information about the CMake mailing list