[CMake] CMP0026 - Disallow use of the LOCATION target property

Stephen Kelly steveire at gmail.com
Fri Feb 6 13:18:31 EST 2015


Jifeng ZHANG wrote:

> Hi,
> 
> I have a question of policy CMP0026. Our project currently is on CMake
> 2 and we are planning to move to CMake 3.

Lot's of questions on that lately. Someone opened the floodgates it seems 
:).

> When we run CMake3.1.1, we get get a few warnings due to the policy
> CMP0026, "Disallow use of the LOCATION target property". Even though
> with those warnings, our cmake scripts still work fine and we are
> getting the property correctly.

> So my question is, will the support of this kind of usage be dropped
> in the future releases? 

Yes. That is the purpose of the policy. Attempting to read the LOCATION will 
eventually be an error. That is not going to happen before CMake 4.0 though.

> If we migrate away from get_target_property, "$<TARGET_FILE> generator
> expression" is suggested from CMake3.1.1's documentation. So to get
> the LOCATION of ${TEST_PROJECT}, I can use:
>   set (TEST_PATH $<TARGET_FILE:${TESTS_PROJECT}>)

This won't work. You need to use the generator expression instead of a cmake 
variable. You use the generator expression in place of ${TEST_PATH} in 
add_custom_command or wherever you use it.

Thanks,

Steve.




More information about the CMake mailing list