[cmake-developers] Listing source-tree files encountered

Clifford Yapp cliffyapp at gmail.com
Sat Jul 18 13:49:17 EDT 2015


On Sat, Jul 18, 2015 at 5:30 AM, Florent Castelli
<florent.castelli at gmail.com> wrote:
> I've used that once and you end up with the relative path to the sources
> from the CMakeLists.txt.
> If you're in another CMakeLists.txt, then you can't use the paths directly.
> I tried a few properties but I couldn't find any property to get the folder
> where the target was defined.
>
> How do you get the full path?

That's a very good point - using the command override approach, the
CMAKE_CURRENT_SOURCE_DIR is always the directory of the target in
question, and looking at our current code I see we do make use of that
assumption.  We would need a way to find out what
CMAKE_CURRENT_SOURCE_DIR was when the target was defined if we're
going to build up a list after the fact - maybe something like
get_target_property(TDIR <targetname> SOURCE_DIR) to get the source
directory in which the target was defined.  In combination with the
SOURCES property it would allow for full path reconstruction.

CY


More information about the cmake-developers mailing list