[CMake] Sharing configuration files?

Raymond Wan r.wan at aist.go.jp
Tue Jun 7 04:11:36 EDT 2011


Hi Hendrik,

Thank you for the suggestions!


On Tue, Jun 7, 2011 at 17:02, Hendrik Sattler <post at hendrik-sattler.de> wrote:
> Zitat von Raymond Wan <r.wan at aist.go.jp>:
>> I think/hope so far things are ok...  I can compile Y and run it with
>> no problems.  The problem is that X needs access to this generated
>> configuration file, too.  At the very least, it needs to know the size
>> of an instance of Y in order to allocate memory for it.
>
> Did you consider alternatives like giving Y a static function that returns a
> new instance of Y? That makes your problem void.
> If this is all within a project that is not going to be separated later,
> just put the common configuration into the parent directory of both


Hmmmmm, I never thought of the first option!  So if I am understanding
your suggestion correctly, this basically means that in X's class
definition, it has an entry like:

Y* instance_y;

i.e., just a pointer to it.  And then X doesn't need to worry about
the size of Y.  I might consider that...

As for your second option, yes, they are all within the same project
-- it's just one isn't a subdirectory of the other (they're siblings).
 I honestly thought that it was "bad practice" to have generated
configuration files outside of the build directory.  But if it is ok,
I might give this second option a try if the first one doesn't work
out.

Actually, my many configuration files is becoming a mess so that first
option is sounding more and more appealing.  :-)  Thank you!

Ray


More information about the CMake mailing list