Storing the source directory will require the exact idea you had mentioned. Use an internal cache variable or, even better, a target property. This is how I have done it. Each target that I create  specifies a list of its include directories (where other targets that depend on it can find its header files, and will append this directory to its list of searchable include directories).<div>
<br></div><div>For defines, and I think cflags, you can use get_target_property().</div><div><br></div><div>For libraries, I&#39;ve also maintained a list in a target property. This is how you build recursive dependencies. CMake will automatically set up build order based on your dependencies, however you cannot query these libraries without maintaining them yourself. Also, another benefit to maintaining dependencies in target properties is that you can throw an error message if a target depends on another target that does not yet exist (used to ensure that targets are defined in the proper order in the cmake scripts).</div>
<div><br></div><div>Hope that helps.<br clear="all"><div><br></div><div>---------</div>Robert Dailey<br>
<br><br><div class="gmail_quote">On Sat, Dec 31, 2011 at 4:45 PM, Gary Kramlich <span dir="ltr">&lt;<a href="mailto:grim@reaperworld.com">grim@reaperworld.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I&#39;m working on a module that needs to interrogate a target, and get<br>
it&#39;s source directory, defines, cflags, and libraries that it links to.<br>
<br>
So far, all I&#39;ve been able to do is get the sources, which are relative<br>
to the source directory of the target.  I have not been able to get the<br>
source directory of the target, so I&#39;m essentially stuck.<br>
<br>
I&#39;ve tried using the LOCATION property on the target, but alas that only<br>
gives me the output location.<br>
<br>
I&#39;ve tried to get the absolute path of a source file using<br>
get_filename_component for the ABSOLUTE property, but it just tacks on<br>
the source filename to the current working directory, which obviously<br>
doesn&#39;t work.<br>
<br>
There is one idea I&#39;ve had to fix this, but it&#39;s by no means ideal, and<br>
that&#39;s to have each target set a property named SOURCE_LOCATION or<br>
something, to CMAKE_CURRENT_SOURCE_DIR but that seems like a huge<br>
inconvenience for potential users.<br>
<br>
Any thoughts?<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Gary Kramlich &lt;<a href="mailto:grim@reaperworld.com">grim@reaperworld.com</a>&gt;<br>
<br>
</font></span><br>--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br></div>