[CMake] Get the BINARY_DIR for a target?

Braden McDaniel braden at endoframe.com
Tue Jan 6 16:21:17 EST 2015


On Tue, 2015-01-06 at 12:34 -0500, Braden McDaniel wrote:
> Are there any properties on a target that I can query to get whatever
> was the CMAKE_CURRENT_BINARY_DIR when the target was defined?
> 
> I'm aware of the LOCATION property; however, its generator-specific
> nature makes teasing the non-generator-specific part out of it rather
> challenging (without some other information about the target
> definition's location in the source tree, which is specifically what I'm
> trying to avoid).  FWIW, I'm writing a function that takes a list of
> targets as input.

It looks like I can add my own arbitrary property for this.  So, my
current solution is to wrap add_library with my own function that calls
add_library and then sets MY_SPECIAL_PROPERTY on the target to the
current value of CMAKE_CURRENT_BINARY_DIR.

Later, I get the value of MY_SPECIAL_PROPERTY inside the function I
described in my previous message.

If someone knows of a better way, do tell.

-- 
Braden McDaniel <braden at endoframe.com>



More information about the CMake mailing list