[CMake] Defer compiler to different file in Visual Studio

2012-03-12 Thread Andreas Haferburg

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.


Thanks,
Andreas

[1] http://www.lazycplusplus.com/index.html
--

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


Re: [CMake] Defer compiler to different file in Visual Studio

2012-03-12 Thread Bill Hoffman

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
--

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


Re: [CMake] Defer compiler to different file in Visual Studio

2012-03-12 Thread Andreas Haferburg

On 12-Mar-12 9:36 PM, Bill Hoffman wrote:

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.


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?


Cheers
Andreas
--

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


Re: [CMake] Defer compiler to different file in Visual Studio

2012-03-12 Thread Bill Hoffman

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

--

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


Re: [CMake] Defer compiler to different file in Visual Studio

2012-03-12 Thread Andreas Haferburg

Bill, thank you for your replies.

I'll be writing a macro for Visual Studio then which finds the 
corresponding cpp file and compiles it.


Cheers
Andreas


On 12-Mar-12 10:26 PM, Bill Hoffman wrote:

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

--

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




--
Scopis GmbH
Blücherstr. 22 / Aufg. 3
10961 Berlin
Germany

E-Mail: ahaferb...@scopis.com
Tel.: +49 (30) 39 82 05 98
Fax.: +49 (30) 39 82 05 99
Internet: www.scopis.com

HRB 128315 Berlin Charlottenburg
USt-IdNr.: DE272721463
Steuernummer: 29/014/02034
Geschäftsführer:  Bartosz Kosmecki

Diese E-mail, einschließlich der Anhänge, ist ausschließlich für den 
oben genannten Adressaten bestimmt und beinhaltet vertrauliche und/oder 
gesetzlich geschützte Informationen. Jedem anderen Empfänger ist die 
Vervielfältigung, Weitergabe oder Veröffentlichung untersagt. Falls Sie 
diese Mitteilung irrtümlicherweise erhalten haben, bitten wir um 
sofortige Information an den Absender und Vernichtung der E-mail.


This e-mail, including the attachments, is for the exclusive use of the 
above-named addresses and contains confidential information and/or 
information protected by law. Any other recipient is prohibited from 
duplicating, passing on to third parties, or publishing this 
information. If by error you are the recipient of this communication 
please inform the sender immediately and permanently delete this e-mail.

--

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