Re: [CMake] How to read and compile dynamically-generated list of cpp files

2014-02-05 Thread Matthew Woehlke

On 2014-02-03 11:44, gimmeamilk gimmeamilk wrote:

I have a custom tool that processes a given list of IDL files and
produces a number of .cpp and .h files as output. I want to add those
files to the list of things to compile in my CMakeLists, and also
model the dependencies those files have on the IDL. To keep things
simple, I will state that any change to any of the IDL files should
trigger a regeneration of all cpp/h.

I have a custom command that takes care of running the generator tool
and listing all the IDL files as dependencies.

My issue is getting the subsequent list of cpp/h files into cmake at
build-time. It is not possible to infer from the name of the IDL files
what cpp files will be generated. My generator tool will, however,
output the list of generated files to a text file.


My usual approach to problems like these is to figure out a way to 
compute the list of output files *without* actually generating them 
(ideally by the generation tool having a mode to do that), and to then 
arrange (1) for that to happen at configure time, and (2) for 
configuration to depend on the input file(s). (For example, generating 
Python bindings with Shiboken is a similar problem.)


Alternatively, you can create an external project that you configure and 
build as part of your build step. (This might work strangely on e.g. 
MSVC, however.)


--
Matthew

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to read and compile dynamically-generated list of cpp files

2014-02-03 Thread J Decker
generate a cmake script and include said script?
use FILE() command and open the file to read it?

On Mon, Feb 3, 2014 at 8:44 AM, gimmeamilk gimmeamilk
gimmeamilkb...@googlemail.com wrote:
 Hi all,

 I have a custom tool that processes a given list of IDL files and
 produces a number of .cpp and .h files as output. I want to add those
 files to the list of things to compile in my CMakeLists, and also
 model the dependencies those files have on the IDL. To keep things
 simple, I will state that any change to any of the IDL files should
 trigger a regeneration of all cpp/h.

 I have a custom command that takes care of running the generator tool
 and listing all the IDL files as dependencies.

 My issue is getting the subsequent list of cpp/h files into cmake at
 build-time. It is not possible to infer from the name of the IDL files
 what cpp files will be generated. My generator tool will, however,
 output the list of generated files to a text file.

 So my question is: how do I instruct cmake to read from this text
 file and add the contents as extra source and header files to be
 compiled, also bearing in mind that the said text file only exists
 during a certain point of the build?

 Many thanks
 --

 Powered by www.kitware.com

 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ

 Kitware offers various services to support the CMake community. For more 
 information on each offering, please visit:

 CMake Support: http://cmake.org/cmake/help/support.html
 CMake Consulting: http://cmake.org/cmake/help/consulting.html
 CMake Training Courses: http://cmake.org/cmake/help/training.html

 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to read and compile dynamically-generated list of cpp files

2014-02-03 Thread Gimmeamilk
A generated CMake script would only be processed at configuration time. I need 
something that gets processed at build time. Thanks

On 3 Feb 2014, at 17:29, J Decker d3c...@gmail.com wrote:

 generate a cmake script and include said script?
 use FILE() command and open the file to read it?
 
 On Mon, Feb 3, 2014 at 8:44 AM, gimmeamilk gimmeamilk
 gimmeamilkb...@googlemail.com wrote:
 Hi all,
 
 I have a custom tool that processes a given list of IDL files and
 produces a number of .cpp and .h files as output. I want to add those
 files to the list of things to compile in my CMakeLists, and also
 model the dependencies those files have on the IDL. To keep things
 simple, I will state that any change to any of the IDL files should
 trigger a regeneration of all cpp/h.
 
 I have a custom command that takes care of running the generator tool
 and listing all the IDL files as dependencies.
 
 My issue is getting the subsequent list of cpp/h files into cmake at
 build-time. It is not possible to infer from the name of the IDL files
 what cpp files will be generated. My generator tool will, however,
 output the list of generated files to a text file.
 
 So my question is: how do I instruct cmake to read from this text
 file and add the contents as extra source and header files to be
 compiled, also bearing in mind that the said text file only exists
 during a certain point of the build?
 
 Many thanks
 --
 
 Powered by www.kitware.com
 
 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ
 
 Kitware offers various services to support the CMake community. For more 
 information on each offering, please visit:
 
 CMake Support: http://cmake.org/cmake/help/support.html
 CMake Consulting: http://cmake.org/cmake/help/consulting.html
 CMake Training Courses: http://cmake.org/cmake/help/training.html
 
 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html
 
 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to read and compile dynamically-generated list of cpp files

2014-02-03 Thread J Decker
Run another layer of cmake that uses the new file?

On Mon, Feb 3, 2014 at 9:33 AM, Gimmeamilk
gimmeamilkb...@googlemail.com wrote:
 A generated CMake script would only be processed at configuration time. I 
 need something that gets processed at build time. Thanks

 On 3 Feb 2014, at 17:29, J Decker d3c...@gmail.com wrote:

 generate a cmake script and include said script?
 use FILE() command and open the file to read it?

 On Mon, Feb 3, 2014 at 8:44 AM, gimmeamilk gimmeamilk
 gimmeamilkb...@googlemail.com wrote:
 Hi all,

 I have a custom tool that processes a given list of IDL files and
 produces a number of .cpp and .h files as output. I want to add those
 files to the list of things to compile in my CMakeLists, and also
 model the dependencies those files have on the IDL. To keep things
 simple, I will state that any change to any of the IDL files should
 trigger a regeneration of all cpp/h.

 I have a custom command that takes care of running the generator tool
 and listing all the IDL files as dependencies.

 My issue is getting the subsequent list of cpp/h files into cmake at
 build-time. It is not possible to infer from the name of the IDL files
 what cpp files will be generated. My generator tool will, however,
 output the list of generated files to a text file.

 So my question is: how do I instruct cmake to read from this text
 file and add the contents as extra source and header files to be
 compiled, also bearing in mind that the said text file only exists
 during a certain point of the build?

 Many thanks
 --

 Powered by www.kitware.com

 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ

 Kitware offers various services to support the CMake community. For more 
 information on each offering, please visit:

 CMake Support: http://cmake.org/cmake/help/support.html
 CMake Consulting: http://cmake.org/cmake/help/consulting.html
 CMake Training Courses: http://cmake.org/cmake/help/training.html

 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to read and compile dynamically-generated list of cpp files

2014-02-03 Thread J Decker
could use configure_file instead of writing the file if you have a
cmakelists.template that has some variables to substitute for the c++
files would be easier

On Mon, Feb 3, 2014 at 9:58 AM, J Decker d3c...@gmail.com wrote:
 Run another layer of cmake that uses the new file?

 On Mon, Feb 3, 2014 at 9:33 AM, Gimmeamilk
 gimmeamilkb...@googlemail.com wrote:
 A generated CMake script would only be processed at configuration time. I 
 need something that gets processed at build time. Thanks

 On 3 Feb 2014, at 17:29, J Decker d3c...@gmail.com wrote:

 generate a cmake script and include said script?
 use FILE() command and open the file to read it?

 On Mon, Feb 3, 2014 at 8:44 AM, gimmeamilk gimmeamilk
 gimmeamilkb...@googlemail.com wrote:
 Hi all,

 I have a custom tool that processes a given list of IDL files and
 produces a number of .cpp and .h files as output. I want to add those
 files to the list of things to compile in my CMakeLists, and also
 model the dependencies those files have on the IDL. To keep things
 simple, I will state that any change to any of the IDL files should
 trigger a regeneration of all cpp/h.

 I have a custom command that takes care of running the generator tool
 and listing all the IDL files as dependencies.

 My issue is getting the subsequent list of cpp/h files into cmake at
 build-time. It is not possible to infer from the name of the IDL files
 what cpp files will be generated. My generator tool will, however,
 output the list of generated files to a text file.

 So my question is: how do I instruct cmake to read from this text
 file and add the contents as extra source and header files to be
 compiled, also bearing in mind that the said text file only exists
 during a certain point of the build?

 Many thanks
 --

 Powered by www.kitware.com

 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ

 Kitware offers various services to support the CMake community. For more 
 information on each offering, please visit:

 CMake Support: http://cmake.org/cmake/help/support.html
 CMake Consulting: http://cmake.org/cmake/help/consulting.html
 CMake Training Courses: http://cmake.org/cmake/help/training.html

 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to read and compile dynamically-generated list of cpp files

2014-02-03 Thread Andreas Mohr
Hi,

On Mon, Feb 03, 2014 at 12:00:02PM -0500, cmake-requ...@cmake.org wrote:
 Date: Mon, 3 Feb 2014 16:44:28 +
 From: gimmeamilk gimmeamilk gimmeamilkb...@googlemail.com

 Hi all,
 
 I have a custom tool that processes a given list of IDL files and
 produces a number of .cpp and .h files as output. I want to add those
 files to the list of things to compile in my CMakeLists, and also
 model the dependencies those files have on the IDL. To keep things
 simple, I will state that any change to any of the IDL files should
 trigger a regeneration of all cpp/h.
 
 I have a custom command that takes care of running the generator tool
 and listing all the IDL files as dependencies.
 
 My issue is getting the subsequent list of cpp/h files into cmake at
 build-time. It is not possible to infer from the name of the IDL files
 what cpp files will be generated. My generator tool will, however,
 output the list of generated files to a text file.
 
 So my question is: how do I instruct cmake to read from this text
 file and add the contents as extra source and header files to be
 compiled, also bearing in mind that the said text file only exists
 during a certain point of the build?

Judging from my (in?)sufficient amounts of CMake experience,
I'd say that's not possible, since we'd be talking build-time (IOW,
generator-type-specific) injection of dependencies into the generated
build system. But then CMake does have some amounts of interesting
features, so I might end up staying corrected
(the only feasible mechanism might be to configure the IDL user side
as an ExternalProject, to have its configure-time activity -
and thus its analysis of the generated text file -
happen during build-time execution of the main project).


I've been spending quite some time integrating (M?)IDL support into my
vcproj2cmake converter, so I know that several IDL compilers have
options for specifying specific files (IID header, proxy header, etc.).
And I'd expect such a capability to be required anyway,
since it's *fixed source files* content which thus has no choice
but to #include *specifically-named* files,
thus the build process would *have to* be able to custom-name
such output file names.
Plus, I can report that on .vc[x]proj files there are
rather liberal possibilities for custom-named patterns
of IDL-related output filenames.
So I'm mildly astonished that one would have a setup where this is NOT
the case.

BTW, it might be very worthwhile to provide an actual CMake LANGUAGE
configuration for your IDL compiler mechanism, for pretty automatic
specification of IDL files etc.
(but perhaps it's wise to choose a language identifier
other than a plain IDL, since CMake might choose
to provide generic IDL support on its own eventually).

HTH (got milk?),

Andreas Mohr
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake