[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    Re: [CMake] ?==?utf-8?q? Debug logging of items
From:       Craig Scott <craig.scott () crascit ! com>
Date:       2019-09-22 19:46:31
Message-ID: CA+dygY=r27sBF6-7Y8tHkS3DV78YqiMj+K8dDciDvwfCeun2Vw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/related)]

[Attachment #4 (multipart/alternative)]


You may want to take a look at the BUILDSYSTEM_TARGETS
<https://cmake.org/cmake/help/latest/prop_dir/BUILDSYSTEM_TARGETS.html>
directory property. It might not be quite what you're looking for, but it
might be close enough. I'm not aware of any way to get a list of all
defined properties on a given target though.


On Mon, Sep 23, 2019 at 12:47 AM Cornelis Bockemühl <cornelis@bockemuehl.ch>
wrote:

> Hi Eric,
>
> Thanks for the hint regarding dumping variables: That's good to know!
>
> However, I was learning that working with CMake is in may ways a question
> of adopting some "good practice", but it is not really being enforced by
> the language. One of the things that are for me part of this good practice
> would be to deal with targets and their dependencies, and properties. Which
> means a certain degree of modularity in the sense that you can easily plug
> projects together by just referring to targets, like by calling
> find_package().
>
> But again: You will never easily know what a package is actually giving
> you - without investing hours and days of code reading - and maybe not even
> then!
>
> But calling some "dump_targets" function after "find_package" (or also
> before and after - for comparison) would give you a chance to know the
> effect of endless "code deserts" with one line of code.
>
> And because this is so fundamental in my eyes, I still almost assume that
> also for targets and properties there must be some function available -
> which I simply have not found yet!??
>
> Or else I would consider this an urgent feature request!
>
> Best regards,
> Cornelis
>
>
> Am Freitag, September 20, 2019 15:07 CEST, Eric Doenges <doenges@mvtec.com>
> schrieb:
>
>
>
>
> I don't know about the targets, but you can get all variables currently
> defined for a directory by reading the VARIABLES property, e.g.
>
> get_property(_variables DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY VARIABLES)
>
> I use this to dump the variables into a file so I can see with which
> variable settings my build directory was configured with.
>
> With kind regards,
> Eric
> Am 20.09.19 um 14:49 schrieb Cornelis Bockemühl:
>
> Right now I am fighting my way through large amounts of CMake code
> (actually working on a ParaView custom application with many own plugins,
> views, domains, property widgets etc. etc.), and it is sometimes really not
> easy not to lose track completely! Sometimes I am happy to be back into
> complex C++ programming - because I see much more logic in the entire
> thing. And it is of course no news that CMake code is not famous for being
> easy to debug.
>
> Anyway, I am dreaming of some "simple" features that would sometimes help
> a lot, and it is all about "dumping" some kind of data. Actually this is
> for me often also the favorite way to debug C++ code: just print out the
> values of variables, arrays, etc. - e.g. if setting a breakpoint in the
> debugger is difficult because you are interested only in the 928773th
> occurrence of a certain piece of code (without even knowing that number...).
>
> Accordingly in CMake code I am working a lot with the message() function -
> but within that code the problem is often that you do not even know which
> variables would be available at all!
>
> Thus functions like would be really great to have:
>
>     "give me a list of all currently known targets"
>     "give me a list of all properties of a target"
>     "give me a list of all currently defined variables"
>     etc.
>
> What I do not know is: Are this things that already exist - in which case
> I would be happy if somebody could tell me how to find them! -, or are
> these functions rather "feature requests"?
>
> In fact I can hardly believe that I am the first with such kind of dreams,
> so my hope is still that they already exist somewhere...
>
>

-- 
Craig Scott
Melbourne, Australia
https://crascit.com

Get the hand-book for every CMake user: Professional CMake: A Practical
Guide <https://crascit.com/professional-cmake/>
Consulting services (CMake, C++, build/release processes):
https://crascit.com/services

[Attachment #7 (text/html)]

<div dir="ltr"><div dir="ltr">You may want to take a look at the <a \
href="https://cmake.org/cmake/help/latest/prop_dir/BUILDSYSTEM_TARGETS.html">BUILDSYSTEM_TARGETS</a> \
directory property. It might not be quite what you&#39;re looking for, but it might \
be close enough. I&#39;m not aware of any way to get a list of all defined properties \
on a given target though.</div><div dir="ltr"><br></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 23, 2019 at 12:47 \
AM Cornelis Bockemühl &lt;<a \
href="mailto:cornelis@bockemuehl.ch">cornelis@bockemuehl.ch</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><p>Hi \
Eric,<br><br>Thanks for the hint regarding dumping variables: That&#39;s good to \
know!<br><br>However, I was learning that working with CMake is in may ways a \
question of adopting some &quot;good practice&quot;, but it is not really being \
enforced by the language. One of the things that are for me part of this good \
practice would be to deal with targets and their dependencies, and properties. Which \
means a certain degree of modularity in the sense that you can easily plug projects \
together by just referring to targets, like by calling find_package().<br><br>But \
again: You will never easily know what a package is actually giving you - without \
investing hours and days of code reading - and maybe not even then!<br><br>But \
calling some &quot;dump_targets&quot; function after &quot;find_package&quot; (or \
also before and after - for comparison) would give you a chance to know the effect of \
endless &quot;code deserts&quot; with one line of code.<br><br>And because this is so \
fundamental in my eyes, I still almost assume that also for targets and properties \
there must be some function available - which I simply have not found \
yet!??<br><br>Or else I would consider this an urgent feature request!<br><br>Best \
regards,<br>Cornelis<br><br><br>Am Freitag, September 20, 2019 15:07 CEST, Eric \
Doenges &lt;<a href="mailto:doenges@mvtec.com" \
target="_blank">doenges@mvtec.com</a>&gt; schrieb:<br>  </p><blockquote type="cite" \
cite="http://92312bde-b740-1b7b-47ff-fa9f91ee3bbb@mvtec.com">  </blockquote><p>I \
don&#39;t know about the targets, but you can get all variables currently defined for \
a directory by reading the VARIABLES property, e.g.</p><p>get_property(_variables \
DIRECTORY &quot;${CMAKE_SOURCE_DIR}&quot; PROPERTY VARIABLES)</p><p>I use this to \
dump the variables into a file so I can see with which variable settings my build \
directory was configured with.</p><p>With kind regards,<br>Eric</p><div \
class="gmail-m_1045032418632976360moz-cite-prefix">Am 20.09.19 um 14:49 schrieb \
Cornelis Bockemühl:</div><blockquote type="cite"><p>Right now I am fighting my way \
through large amounts of CMake code (actually working on a ParaView custom \
application with many own plugins, views, domains, property widgets etc. etc.), and \
it is sometimes really not easy not to lose track completely! Sometimes I am happy to \
be back into complex C++ programming - because I see much more logic in the entire \
thing. And it is of course no news that CMake code is not famous for being easy to \
debug.<br><br>Anyway, I am dreaming of some &quot;simple&quot; features that would \
sometimes help a lot, and it is all about &quot;dumping&quot; some kind of data. \
Actually this is for me often also the favorite way to debug C++ code: just print out \
the values of variables, arrays, etc. - e.g. if setting a breakpoint in the debugger \
is difficult because you are interested only in the 928773th occurrence of a certain \
piece of code (without even knowing that number...).<br><br>Accordingly in CMake code \
I am working a lot with the message() function - but within that code the problem is \
often that you do not even know which variables would be available at \
all!<br><br>Thus functions like would be really great to have:<br><br>       "give me \
a list of all currently known targets"<br>       "give me a list of all properties of \
a target"<br>       "give me a list of all currently defined variables"<br>       \
etc.<br><br>What I do not know is: Are this things that already exist - in which case \
I would be happy if somebody could tell me how to find them! -, or are these \
functions rather &quot;feature requests&quot;?<br><br>In fact I can hardly believe \
that I am the first with such kind of dreams, so my hope is still that they already \
exist somewhere...</p></blockquote></div></blockquote></div><br \
clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div \
dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr">Craig Scott<br><div>Melbourne, \
Australia</div><div><a href="https://crascit.com" \
target="_blank">https://crascit.com</a><br></div><div><br></div><div>Get the \
hand-book for every CMake user:  <a href="https://crascit.com/professional-cmake/" \
target="_blank">Professional CMake: A Practical Guide</a><br></div><div>Consulting \
services (CMake, C++, build/release processes): <a \
href="https://crascit.com/services" \
target="_blank">https://crascit.com/services</a></div></div></div></div></div></div></div></div></div></div></div></div>



["62A4-5D878980-D-69A20B00" (image/png)]

-- 

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:
https://cmake.org/mailman/listinfo/cmake



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic